Day 3-Basic Linux Commands

This Small Blog will cover basic Linux Commands.

1-To view what's written in a file.

Use Cat Command in Linux Terminal

cat hello.txt

The above command will print the outlet of the hello.txt file in the console itself.

2-To change the access permissions of files.

The Chmod command to change the access permissions of the files is used

a file and directory can have read write and execute permissions

rwx which is equal to 421 in numerical form.

Suppose You have a file named test.txt inside a directory test_folder

Type ls -la to get the list of permission given to that file

rw_ ___ ___ test.txt

The above output will represent that the owner of the file has read and write permission, group users have no permissions while other users also have no permissions.

To allow owner,group users and other users to access the file we will use

chmod 777 text.txt

3-To check which commands you have run till now.

history

4-To remove a directory/ Folder.

rm -rf directoryname

5-To create a fruits.txt file and view the content.

echo "hello world">fruits.txt
cat fruits.txt

6-Add content in devops.txt (One in each line) - Apple, Mango, Banana, Cherry, Kiwi, Orange, Guava.

echo Apple >devops.txt
echo Mango >>devops.txt
echo Banana >>devops.txt
echo Cherry >>devops.txt
echo Kiwi >>devops.txt 
echo Orange >>devops.txt
echo Guava >>devops.txt

7-To Show only the top three fruits from the file.

cat devops.txt | head -3

8-To Show only bottom three fruits from the file.

cat devops.txt |tail -3

9-To create another file Colors.txt and view the content.

echo Red >Colors.txt
echo Pink >>Colors.txt
echo White >>Colors.txt
echo Black >>Colors.txt
echo Blue >>Colors.txt
echo Orange >>Colors.txt
echo Purple >>Colors.txt
echo Grey >>Colors.txt

10- To find the difference between the devops.txt and Colors.txt file.

diff devops.txt Colors.txt