Вы находитесь на странице: 1из 9

JOURNAL ASSIGNMENT:

12 WEEKS REFLECTION
Ashley Pearson

STARTING OUT: WORDS OF A BEGINNER

The wonderful thing about being a beginner; you’re unbiased. You don’t have a particular view on a subject,
you’re open to new things and it’s exciting to learn. Even the most basic task for others can be a challenge to
learn or understand, and that’s perfectly fine. I think that’s one of my favorite things about learning something
new, I don’t really have a preference yet, I’m open to new things. This class was wonderful in the sense of
touching something new. In the beginning I had a very basic amount of knowledge and no idea where to even
start as far as learning commands go, this steered me in the right direction and allowed me to explore different
Linux distributions. For this journal I used the OS Manjaro KDE.
FIRST STEP: LS

I keep coming back to this command, I find it incredibly useful. I am consistently inconsistent when it comes to
remembering files within a directory while I am working. The basic ls command without options lists files within a
directory (Fig. 1). I learned that ls stands for “list segments”.

Fig. 1 Use of ls without options

Earlier in the semester we researched inodes where I learned a few ls options. ls -li displays inode number, file
permission, owner & group ID, number of hard links to the file, creation date and file name (Fig. 2).

Fig. 2 Use of ls -li command

Bonus: The option ls -a lists hidden files starting with “.” (Period) or ls -alh (Fig. 3). Tacking a h on the end makes
file sizes and other amounts more human-readable You cannot see hidden files with the basic ls command.

Fig. 3 Use of ls -alh command. Example of how files appear when command is executed in human-readable format.

2
BEYOND LS: CD, PWD, MAN

After we explored ls, we moved onto cd (change directory). We used this command to navigate to and from
directories within our file system. There are a few different options with cd, moving forward into a specific
directory, backwards out of it and straight back to the root directory (Fig. 4). In addition, pwd (print working
directory) displays the full pathname of the working directory you are in (Fig. 5). Next, we covered man, which
displays the manual page for a command and in this example, I used man ls (Fig. 6).

Fig. 4 Use of various cd commands

Fig. 5 Use of pwd command

Fig. 6 Use of man ls command to display the manual for ‘ls’, very long this was only the first of 200+ lines

3
CAT IN ALL (SOME?) OF ITS GLORY

The cat command was another early one I learned, it allows you to create files, look at the contents of a file, and
link files together. You can also view the contents of two or more files in the order you list them. In the image
below, I created two different files then viewed both together with the cat command (Fig. 7). There are quite a few
options for cat, but I felt these were useful and should be included.

Fig. 7 Use of cat commands

If you want to display line numbers in your file, your command would be, cat -n filename (Fig.8)

Fig. 8 Use of cat -n command

If you want to append one file to another, you would use the command cat file >> file2 (Fig. 9)

Fig. 9 Use of append command

4
CREATING/REMOVING A DIRECTORY

Since we have gone over how to create files, its useful to know how to create a directory to store them in. The
command mkdir {name}, will do just that (Fig. 10) However, if a space is added it will create two (2) + separate
directories depending on how many spaces you have.

Fig. 10 Use of mkdir command

Now, say for instance I made a directory I don’t have a use for and want to delete it, I would use the command
rm -r {directoryname} (Fig. 11). If you are not in the root account or an administrator, you will need to execute the
sudo (super user do) command, sudo rm -r {directoryname}. Executing this command will delete all files within
that directory.

Fig. 11 Use of rm -r command

Bonus: When creating a directory, the basic command mkdir {directoryname} will not give a confirmation if it was
created. If you would like a confirmation, the command in addition to the option -v, will display the message
“mkdir: created directory ‘directoryname’ “(Fig. 12).

Fig. 12 Use of -v option with mkdir command

It is also possible to create a directory and set permissions at the same time, mkdir -m700 {dirname} (Fig. 13).
This command, in combination with -m700 gives everyone access to that directory. In the next section I will go
over how to assign file/directory permissions to specific user.
700 = full permissions
D = directory, R = read, W = write, X = execute.
drwxr-xr-x is the default permission set of a newly created directory. It means the owner can list its contents,
create new files inside it and access it and members of the directory group can list contents and access it.

Fig. 13 Use of mkdir command in combination with -m700 option

5
+/- CHANGING FILE AND DIRECTORY PERMISSIONS

The chmod (change mode) command will add and remove permissions of specific files. I wanted to include
something basic, quick and easy to remember. The directory “dir” gives other users way too many permissions, I
want it to be only read permissions across the board. I would execute the command, chmod -wx {name} (Fig. 14)
or if I wanted all of it gone, chmod -rwx {name}. Now what if I want to add write permissions to this directory? I
would use the command chmod +rwx {name} and it would add permissions.

Fig. 14 Use of chmod -wx command

It is also possible to add/remove permissions for group owners and others/users. G = group, O = others. The
command chmod g/+w {name} will give group owners/others write permissions (Fig. 15)

Fig. 15 Use of chmod command with g & o + write options

This was just a basic way to do it, every user, group, etc. is under a “number” system. 777 meaning full
permissions for everyone, 700 will give rwx permission for the user and no one else.
Permission numbers:
0 = ---

1 = --x

2 = -w-

3 = -wx

4 = r-

5 = r-x

6 = rw-

7 = rwx

6
GREP/REGEX – SEARCHING PLAIN-TEXT

The grep command is a way to show or match literal patterns, phrases, numbers, etc in a plain text file. It will
print out every word line that contains the word or number you are searching for. Grep has a few different useful
options, grep -I “word” {filename} (Fig. 16). If we wanted to exclude lines with a specific word, the grep command
including the -v option; grep -vn “word” {filename} would do that, tacking the n option will also show you the line
number. (Fig. 17) However, it is case sensitive. In the file I wrote multiple lines of the same sentence just different
formats.

Fig. 16 Use of command grep -I “word” {filename}

Fig. 17 Use of command grep -vn “word” {filename}

Bonus: We can also append specific lines of a file into another file (Fig. 18) using the command;
grep “text” {filename} >> filename

Fig. 18 Use of command grep “text” {filename} >> filename

7
BONUS INFORMATION

Regex has a simple goal, identify and display strings that match a given expression. In use, RegEx takes an
expression generated by the user and searches an input string or file for instances where the expression matches
the text. Using "[A-Za-z]" will select all characters that lie in the English alphabet, capital or lowercase. Simply
using "[A-Z]" selects all upper-case letters, and so on and so forth. In network security, I think we can sift through
logs and large data sets with ease when combined with grep. Dashboards can be simplified and only alert the
analyst in the event of specific qualifications being met, though I'm not sure how practical this is.

apt-get (pacman for Arch/Manjaro) vs homebrew: APT, Advanced Packaging Tool, handles the installation and
removal of software on Debian, Ubuntu and most other Linux distributions. apt-get is the command used with APT
software packages. You can use it to upgrade, install, uninstall, purge, etc. There are at least 15 commands you
can use with apt-get and even more options. Apt-get is a little easier to understand, and it’s been easier for me to
remember as far as knowing exactly what a command will do. I’ve realized many apt-get commands require
administrator privileges, especially if you are trying to install libraries, packages, etc. An example; apt-get
download ruby, which the file will have the .deb extention and you would install the package manually with dpkg –
install (computerhope, 2018)

Homebrew is the macOS equivalent of apt-get. It is a package manager that deals with installation. It pretty much
installs what you want. An example of the difference of the two would be “brew install wget” vs “apt-get install”.
Homebrew is written in Ruby, while APT is written in C++, a little bit of a difference there. Personally, I have never
used a mac, so homebrew was news to me. I’ve found the commands look a little similar, mac being unix-based,
so that’s obvious. The syntax is pretty interesting and some of the names for commands are great, for instance
when troubleshooting you would run the commands brew update(twice) then brew doctor (brew.sh,
2017). Looking into this honestly made me want to boot a macOS VM to try out homebrew, I feel like I would get
a better look into the differences.

8
REFERENCES

13 Basic Cat Command Examples in Linux. (2012, August 25). Retrieved from https://www.tecmint.com/13-
basic-cat-command-examples-in-linux/

How do I remove a full directory in Linux? (2018, January 24). Retrieved from
https://www.computerhope.com/issues/ch000798.htm

Linux / Unix: Find And List All Hidden Files Recursively - nixCraft. (2018, January 5). Retrieved from
https://www.cyberciti.biz/faq/unix-linux-centos-ubuntu-find-hidden-files-recursively/

Linux File Permissions. (2011, December 14). Retrieved from https://www.pluralsight.com/blog/it-ops/linux-file-


permissions

ls command in Linux/Unix | list files/directories. (n.d.). Retrieved from


https://www.rapidtables.com/code/linux/ls.html#options

Newell, G. (2016, March 9). How to Create Directories In Linux With The "mkdir" Command. Retrieved from
https://www.lifewire.com/create-directories-linux-mkdir-command-3991847

What is the difference between cd .. and cd\ or cd / commands. (2018, January 24). Retrieved from
https://www.computerhope.com/issues/ch001310.htm

Вам также может понравиться