Basic Linux Commands

What is Linux?

Linux is a free and open-source operating system created by Linus Torvalds in 1991. Unix is the base of the Linux operating system.

Linux has some features like it is more secure and flexible.

The very popular version of Linux is Ubuntu, CentOSand Red Hat Enterprise Linux.

Some examples of different ls commands in Linux :

ls - The command lists all the files and directories in the current working directory :

$ ls
'3D Objects'/         Documents/               Music/                                                                                         NetHood@        Searches/         ntuser.dat.LOG2
 AppData/             Downloads/              'My Documents'@

ls -a - This command lists all files and directories, including hidden files :

$ ls -a
 ./              .vscode/             Documents/              'My Documents'@

ls -l - The command lists files and directories in a long list format with extra information like permission, size, date, and time :

$ ls -l
total 6617
drwxr-xr-x 1 Sarvadnya 197609       0 Jul 15  2022 '3D Objects'/
drwxr-xr-x 1 Sarvadnya 197609       0 Jul 15  2022  AppData/
lrwxrwxrwx 1 Sarvadnya 197609      34 Jul 15  2022 'Application Data' -> /c/Users/Sarvadnya/AppData/Roaming/
drwxr-xr-x 1 Sarvadnya 197609       0 Jul 15  2022  Contacts/
lrwxrwxrwx 1 Sarvadnya 197609      62 Jul 15  2022  Cookies ->

ls -la - The commands give more information about files, folders, and hidden files and folders :

$ ls -la
total 6040
drwxr-xr-x 1 Sarvadnya 197609       0 Mar  6 11:38  ./
drwxr-xr-x 1 Sarvadnya 197609       0 Feb 17 11:12  ../
-rw-r--r-- 1 Sarvadnya 197609      58 Mar  9 11:59  .bash_history
-rw-r--r-- 1 Sarvadnya 197609     220 Mar  6 11:38  .gitconfig
-rw-r--r-- 1 Sarvadnya 197609      20 Feb 17 21:20  .lesshst
drwxr-xr-x 1 Sarvadnya 197609       0 Aug  5  2022  .ms-ad/

ls -lh - This command lists files and directories in long format with human-readable file sizes:

$ ls -lh
total 6.1M
drwxr-xr-x 1 Sarvadnya 197609     0 Jul 15  2022 '3D Objects'/
drwxr-xr-x 1 Sarvadnya 197609     0 Jul 15  2022  AppData/
lrwxrwxrwx 1 Sarvadnya 197609    34 Jul 15  2022 'Application Data' -> /c/Users/Sarvadnya/AppData/Roaming/
drwxr-xr-x 1 Sarvadnya 197609     0 Jul 15  2022  Contacts/
lrwxrwxrwx 1 Sarvadnya 197609    62 Jul 15  2022  Cookies ->

Directory commands :

pwd - < Print working directory > The command displays the current working directory :

$ pwd
/c/Users/Sarvadnya

mkdir- < make directory > The command is used to create a new directory in the current working directory:

$ mkdir devops

cd - < change directory > The command to navigate through directories:

$ cd devops

rmdir - The command used to remove directories or folders:

$ rmdir devops

touch - The touch command is used to create a new file. For example, to create a new file:

$ touch devops

cat - The cat command reads the content of a file:

$ cat devops

mv [old_name] [new_name] - The command used to Rename a file or directory:

  $ mv file1.txt file2.txt

rm - The command used to delete or remove files:

$ rm file1.txt

history - The command used to see all commands that have been used:

$ histroy

Thanks for reading.

  • Vaibhav_Chavan