Basic commands in linux

Ls (list directories)

*This command is used to list all the files and directories under a directory.

Header and switches of ls command-

  • Ls -a : Represents all files and directories in the listing
  • Ls -A : It do not list the hidden files which have  ‘.’  or  ’..’
  • Ls -d : List directories themselves, not their contents.
  • Ls -g : it list the groups which displays the group ownership of files and directories rather than the owner.
  • Ls -h : Print the files which are in human readable format sizes like 1K ,234M, 2G, etc
  • Ls -i : it is Also known as inode which prints the index number of each file
  • Ls -I : it is Also known as longformat which prints the detailed information about files and directories in a clear representable format.
  • Ls -S : this command helps the user to sort the files and directory in an order according to the size (largest to smallest)
  • Ls -t :  this command helps in Sorting files and directories by the last changes or modification done by the user

Cd command(change directory)

This command allows you to change directories in Linux, making it easier to navigate through the file system and manage your files efficiently.

To change your path from one directory to another use (cd)command in linux (cd [directory name])replace the directory name with the desired directory in which you want to enter

Suppose directory name is profile

-Now suppose the user want to go to a file or directory which has a long path for long paths user can again use cd command to reach the desired location just by using ‘/’ for example a directory is in some another directory where the directory is located user is supposed to give command like this-

– Use of ‘.’  ’..’

It is the most commonly used command for cd command as it is used to go in previous directory or file use for the ‘.’ and ‘..’ is very easy single ‘.’ Takes the user to just one step back to the previous directory or file whereas ‘..’ takes the user two step back.

Pwd command (print working directory)

 This command is very commonly and very usefully used by the user as it helps the user to Print the full filename of the current working directory and also It prints the path of the current working directory.

It has 2 flags

Pwd -L =provides the path with symlinks

Pwd -p=provides the clear path without symlinks

Note: symlinks are the symbolic linux/UNIX link that points to another file or directory in your system.

Pwd -L(logical) : Shows the logical path which includes symbolic links. This option respects any symbolic links in the path, means if you navigate to the current directory through a symbolic link, pwd -L command will display the path with the symbolic link.

Pwd -P(physical): Shows the physical path, which resolves symbolic links to their real path, underlying paths. This option outputs the actual directory structure on disk, by not printing any symbolic links.

Leave a Comment