Now that you have had some time to mess around with pwd, ls -lah, and cd it is time to kick it up a notch. Lets start with another simple command called, cat. What this does is display the contents within a file.

Here is an example when you cat a file:

cat lotr.txt
Gandalf Wizard 2019
Aragorn Man 87
Gimli Dwarf 139
Samewise Hobbit 38
Legolas Elf 2931
Frodo Hobbit 50
Merry Hobbit 36
Pippin Hobbit 28
Boromir Man 41

You can also use a command called stat to show you all the details about a file. This helps me with looking at the permissions easier since I have always had a hard time reading the permissions from the left side of the screen.

Here is an example when you stat a file:

stat lotr.txt
File: ‘lotr.txt’
Size: 152 Blocks: 8 IO Block: 4096 regular file
Device: fd02h/64770d Inode: 809616501 Links: 1
Access: (0644/-rw-r–r–) Uid: ( 0/ root) Gid: ( 0/ root)
Context: unconfined_u:object_r:home_root_t:s0
Access: 2017-04-09 11:35:04.393924482 -0500
Modify: 2017-04-09 11:34:41.359142194 -0500
Change: 2017-04-09 11:34:41.359142194 -0500

This will show the permissions, the ownership, inode, ect of the file.

The next command we will learn is how to make a copy of a current file that you have. It is very good to get in the habit of making copies of files all the time when making any changes to a file first.

How to copy a file using the cp command:

cp -vi lotr.txt lotr.txt.bak

ls -lah
total 16K
-rw-r–r–. 1 johnno johnno 717 Jan 10 00:49 !
drwxr-xr-x. 2 johnno johnno 70 Apr 9 11:48 .
drwxr-xr-x. 5 johnno johnno 56 Apr 9 11:27 ..
-rw-r–r–. 1 johnno johnno 717 Jan 10 00:49 awkfile.txt
-rw-r–r–. 1 root root 152 Apr 9 11:34 lotr.txt
-rw-r–r–. 1 root root 152 Apr 9 11:48 lotr.txt.bak

You can now see that we have a backup of the file lotr.txt.  Another proper way of doing this is adding an epoch time stamp to it.

Example how to copy a file with an Epoch time stamp:

cp -vi lotr.txt lotro.txt$(date +%s).bak

ls -lah
total 20K
-rw-r–r–. 1 johnno johnno 717 Jan 10 00:49 !
drwxr-xr-x. 2 johnno johnno 101 Apr 9 11:54 .
drwxr-xr-x. 5 johnno johnno 56 Apr 9 11:27 ..
-rw-r–r–. 1 johnno johnno 717 Jan 10 00:49 awkfile.txt
-rw-r–r–. 1 root root 152 Apr 9 11:53 lotro.txt1491756797.bak
-rw-r–r–. 1 root root 152 Apr 9 11:34 lotr.txt
-rw-r–r–. 1 root root 152 Apr 9 11:48 lotr.txt.bak

What this does is add a time stamp to it from when you copied  the file. If you want to see it in human readable form you can simply run this command:

date -d @1491756797
Sun Apr 9 11:53:17 CDT 2017

To Be Continued ………