Linux Commands: Normal user
mkdir
ls
tree
yum install
apt-get
cd
pwd
rmdir
touch
All the commands in Linux r lower cases -case sensitive.
windows we called as folders lly
in Linux we called as directory
I want to create a directory? how ?
mkdir [options...][dirnames...]
create a directory & it will not display anything whether created or not?
mkdir --version
It displays the version number, some information regarding the license and exits.
mkdir --help
It displays the help related information and exits.
Readers Top Picks
Fundamentals of the Linux file system
mkdir -v/--verbose
It displays a message for every directory created.
mkdir -p [directories]
A flag which enables the command to create parent directories as necessary.
If the directories exist, no error is specified
mkdir -p first/second/third
If the first and second directories do not exist, due to the -p option, mkdir will create these directories for us.
mkdir -m a=rwx [directories]
This option is used to set the file modes, i.e. permissions, etc. for the created directories. The syntax of the mode is the same as the chmod command.
ls command
ls is a Linux shell command that lists directory contents of files and directories.
Exploring the Linux Filesystem
ls -t
It sorts the file by modification time, showing the last edited file first.
ls -1
Display One File Per Line Using ls -1
ls -l
To show long listing information about the file/directory.
-rw-rw-r– 1 maverick maverick 1176 Feb 16 00:19 1.c
In the example above the hyphen (-) in the 1st character indicates that this is a normal file.
Field Explanation
– normal file
d : directory
s : socket file
l : link file
ls -lh (h stands for human readable form)
To display file size in easy to read format. i.e i.e M for MB, K for KB, G for GB.
ls -ld /etc
Display Directory Information
ls -lt
To sort the file names displayed in the order of last modification time
ls -ltr
Order Files Based on Last Modified Time (In Reverse Order) Using ls -ltr
ls -a/ls -A
To show all the hidden files in the directory, use ‘-a option’. Hidden files in Unix starts with ‘.’
in its file name.It will show all the files including the ‘.’ (current directory) and ‘..’ (parent directory).
ls -R
Display Files Recursively Using ls -R
ls /etc/opt
ls -R /etc/opt
ls -i
Display File Inode Number Using ls -i
ls -i /etc/opt
tree
if u want to dislay like tree structure u need to install
login with root sudo su -
yum install tree
yum install tree -y
once installation done then execute tree cmd
suppose u want to install any s/w in ubuntu
apt
or
apt-get
cd [directory]
cd command in linux known as change directory command. It is used to change current working directory.
cd /:
this command is used to change directory to the root directory, The root directory is the first
directory in your filesystem hierarchy.
cd dir_1/dir_2/dir_3
This command is used to move inside a directory from a directory
cd ~ [or] cd
this command is used to change directory to the home directory.
cd ..
this command is used to move to the parent directory of current directory, or the directory one
level up from the current directory. “..” represents parent directory.
pwd
pwd stands for Print Working Directory. It prints the path of the working directory, starting from the root.
pwd is shell built-in command(pwd) or an actual binary(/bin/pwd).
pwd -L: Prints the symbolic path.
pwd -P: Prints the actual path.
rmdir
command is used remove empty directories from the filesystem in Linux.
The rmdir command removes each and every directory specified in the command line only if these directories are empty.
So if the specified directory has some directories or files in it then this cannot be removed by rmdir command.
rmdir –help
rmdir -p mydir/mydir1
This will first remove the child directory and then remove the parent directory.
rmdir mydir1 mydir2 mydir3
Remove the directories mydir1, mydir2, and mydir3, if they are empty. If any of these directories are not empty
Then an error message will be printed for that directory, and the other directories will be removed.
rmdir mydir/mydir1 mydir
Remove the directory mydir/mydir1 if it is empty. Then, remove directory mydir, if it is empty after mydir/mydir1 was removed.
touch file_name
It is used to create a file without any content/empty file
touch File1_name File2_name File3_name
Touch command can be used to create the multiple numbers of files at the same time. These files would be empty while creation.
touch -a fileName
This command is used to change access time only. To change or update the last access or modification times of a file touch -a command is used.
touch -c fileName
This command is used to check whether a file is created or not. If not created then don’t create it. This command avoids creating files.
touch -c-d fileName
This is used to update access and modification time.
touch -m fileName
This is used to change the modification time only. It only updates last modification time.