CyberSecurity part 4
So on to video 2 of 8, I will maintain the login link so that you don't need to go hunting back through previous posts.
So this episode looks at how we can view the content of text files, which are used for pretty much everything on GNU / Linux system.
On a very basic level, the echo command will send the contents of a file to the screen
cat – which is short for conCATenate is good for looking at short files, however sometimes we have files that are longer than the screen can display so we can use the less command
The less command stops displaying contents and then allows us to view more lines by pressing enter on the keyboard, press q to quit this program.
You can also apply this to more than one file
cat file1.txt file2.txt
we can also pipe output of cat in to less e.g
cat /etc/fstab | less to get the same effect
Sometimes we need to add a single line to the end of a file (append) we can add another like to the end of file.txt with:-
echo “new text” >> file.txt
You can also append the contents on one file to the end of another
cat file1.txt >> file2.txt
To edit a file in more depth, we need to use an editor such as nano
So nano /etc/fstab will open the file as read only,* this is because files such as /etc/fstab re read only to normal users, in order to edit, you need to elevate your privileges using sudo.
sudo nano /etc/fstab
You will need to enter your password to proceed at this point, of course your user needs to be part of the sudoers list in order to do this, otherwise you get reported to your sysadmin. Ubuntu based distributions use sudo to elevate permissions by default, Debian using root / user set up so you have to use su unless you set your system user up to use sudo.