Here are some basic linux commands which can get you started.
View contents of a file.
Command: cat <filename>
for eg. cat day3.sh
Change access permissions of file.
To understand file permissions we need to understand what all groups are present in Linux and what file permissions we can assign to them.
We have three groups in Linux:
users: permissions will be applied to all users
groups: permissions will be applied to a group of users
others: any users that are not part of users and groups
Linux File Permissions:
Read: this will provide read permission to the file
Write: this will provide write permission to the file
Execute: this will provide execution permission to the file
As shown in the image above Users has rwx which means read, write, and execute permissions.
Groups have access to execute the file whereas others have access to read and execute.
Command : chmod <filepermission> <filename>
for eg. chmod 766 day3.sh
Check history of commands:
To check list of commands you previously ran use history command as shown below:
This will give you a list of commands.
Remove a directory/folder:
To remove a directory use rm command as shown below:
The -rf flag will ensure the forceful deletion of files in recursive format.
Create a text file and add contents.
To create a text file use vim command as shown below:
vim <filename>
To add content to this file click and which will open vim editor mode.
Type contents in the file as shown below:
Enter "i" which will enable insert mode.
After entering the content, save your work using " wq! "
Check the top/bottom contents of the file.
To check top contents use the head command.
head -n <filename>
e.g head -3 fruits.text
To check bottom contents use the tail command.
tail -n <filename>
e.g tail -3 fruits.txt
Check the difference between the two files.
diff command will show you difference between two files.
diff <filename1.txt> <filename2.txt>
for eg. diff fruits.txt color.txt