Basic Linux Command - Part 2

vivek singhvivek singh
2 min read

We can create Directory in Linux with the use of mkdir command.

mkdir - Make Directory

  1. To create a directory. Run mkdir command

# mkdir dir name

ex- #mkdir d1 D1 is the dir name.

  1. To create multiple directories

#mkdir d2 d3 d4

  1. To change a directory from the current directory:-

#cd <dir name>

ex- cd d1

  1. To recursively created directories:-

#mkdir -p india/blr

  1. To go back to one directory up:

#cd ..

  1. To go back directly to a home directory of the current user from any location in the system:

#cd

  1. Create the hidden file or dir:-

#touch .f1

#mkdir .d5

  1. To check hidden files #ls -a

  1. To copy file

    #cp source destination

    #cp f3 f4

    #cat f4 - Here you will see f3 content.

  1. To Move file or dir:-

    #mv source destination - cut and paste

    #mv f1 d1

    #mv d1 d2

  1. Rename File or Dir.

    #mv oldname newname

    #mv f4 newf4

  1. Remove file or Dir.

    rmdir remove specified dir (empty)

    rmdir -p remove both parent and child dir

    rm -rf remove even non-empty files and dir

    rm -r remove empty dir

    rm -rp removes non-empty dir including parent & subdirectory

    -r = remove

    -rf = remove forcefully

Using the command line to get help:-

#whatis - one line output

#man - All details about the command

#apropos - all commands in a system that contain a specific keyword

ex- #whatis date

#man touch

SHELL in Linux:-

-The shell is the Linux command line interpreter. It provides an interface between the user and the kernel and executes programs called commands.

-For example, if a user enters ls then the shell executes the ls command.

- Shell types:-

Bourne shell (sh)

c shell (csh)

Korn shell (ksh)

z shell (ssh)

Bourne again shell (BASH).

- To check shell type:

#echo $SHELL

- Command Alias:

#alias dt=date

#alias dir=mkdir

#alias ip=ifconfig

0
Subscribe to my newsletter

Read articles from vivek singh directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

vivek singh
vivek singh

5+ year of Experienced System admin with a demonstrated history of working in the outsourcing/offshoring industry. Skilled in Windows Server, Mac administration Networking,G-suit, o365, Red hat linux, okta admin ,jira , Slack admin, Asset, Servers. Strong information technology professional with a B.Tech (cs) focused in Computer Science from jaipur national university, jaipur.