Ls Is A Linux Shell Command That Lists Directory Contents of Files and Directories
Ls Is A Linux Shell Command That Lists Directory Contents of Files and Directories
ls- ls is a Linux shell command that lists directory contents of files and directories
• -l -r -la -s -f -h -author -t -a ll
2. cd- The Cd (“change directory”) command is used to change the current working directory
in Linux operating systems. It is one of the most basic and frequently used commands when
working on the Linux terminal.
• Mkdir Directory_name
4.cat- The cat (short for “concatenate“) command is one of the most frequently used
command in Linux operating systems. cat command allows us to create single or multiple files,
view contain of file, concatenate files and redirect output in terminal or files.
• Syntax- cat > filename.txt
• To append- cat >> filename.txt
5. cd! $- denotes the last argument from the previous command . It will point the location
of dirs.. (example with mkdir)
• -i
• -b
• -l
9.mv-mv stands for move. mv is used to move one or more files or directories from one
place to another in file system like UNIX. It has two distinct functions:
(i) It rename a file or folder.
(ii) It moves group of files to different directory.
10.rm-rm stands for remove here. rm command is used to remove objects such as files,
directories, symbolic links and so on from the file system like UNIX. To be more precise, rm
removes references to objects from the filesystem, where those objects might have had
multiple references (for example, a file with two different names). By default, it does not
remove directories
11.rmdir-( rmdir or rd ) 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. ( Exaple with rm)
13.less- Less command is Linux utility which can be used to read contents of text file one
page(one screen) per time. It has faster access because if file is large, it don’t access complete
file, but access it page by page. For example, if it’s a large file and you are reading it using any
text editor, then the complete file will be loaded to main memory, but less command don’t load
entire file, but load it part by part, which makes it faster.
Syntax: less filename.
14. head: The head command, as the name implies, print the top N number of data of the
given input. By default, it prints the first 10 lines of the specified files. If more than one file name
is provided then data from each file is preceded by its file name.
15. tail: The tail command, as the name implies, print the last N number of data of the
given input. By default, it prints the last 10 lines of the specified files. If more than one file name
is provided then data from each file is precedes by its file name.
16.more-more command is used to view the text files in the command prompt, displaying
one screen at a time in case the file is large (For example log files). The more command also allows
the user do scroll up and down through the page. The syntax along with options and command is
as follows. Another application of more is to use it with some other command after a pipe. When
the output is large, we can use more command to see output one by one.
17.chmod- If you own a file, you can change its permission with “chmod”
18. chown- Change the owner of the file( example with chmod)
19. chgrp- Change the group of the file.
20.chsh- chsh command in Linux is used to change the user’s login shell(currently login
shell). Shell is an interactive user interface with an operating system and can be considered an
outer layer of the operating system. The bash shell is one of the most widely used login shells in
Linux. This command allows the user to change the shell from the current shell. It can also give
warning if the shell is not present in the /etc/shells file. The superuser can change the login shell
for the existing accounts.
21.ps- Linux provides us a utility called ps for viewing information related with the processes
on a system which stands as abbreviation for “Process Status”. ps command is used to list the
currently running processes and their PIDs along with some other information depends on
different options. It reads the process information from the virtual files in /proc file-system.
/proc contains virtual files, this is the reason it’s referred as a virtual file system.
22.top- top command is used to show the Linux processes. It provides a dynamic real-time
view of the running system. Usually, this command shows the summary information of the
system and the list of processes or threads which are currently managed by the Linux Kernel.
As soon as you will run this command it will open an interactive command mode where the top
half portion will contain the statistics of processes and resource usage. And Lower half contains
a list of the currently running processes. Pressing q will simply exit the command mode.
23.kill- kill command in Linux (located in /bin/kill), is a built-in command which is used to
terminate processes manually. kill command sends a signal to a process which terminates the
process. If the user doesn’t specify any signal which is to be sent along with kill command then
default TERM signal is sent that terminates the process.
24.who- The who command is used to get information about currently logged in user on to
system.
who command is used to find out the following information :
1. Time of last system boot
2. Current run level of the system
3. List of logged in users and more.
25.whoami- whoami command is used both in Unix Operating System and as well as
in Windows Operating System.
• It is basically the concatenation of the strings “who”,”am”,”i” as whoami.
• It displays the username of the current user when this command is invoked.
• It is similar as running the id command with the options -un.
( ex. with who)
26.du- du command, short for disk usage, is used to estimate file space usage.
The du command can be used to track the files and directories which are consuming excessive
amount of space on hard disk drive.
• If we want to print sizes in human readable format (K, M, G), use -h option
• Use -a option for printing all files including directories
• To print sizes till particular level, use -d option with level no.
• Get summary of file system using -s option
• Get the timestamp of last modified using --time option
27.df- The df command (short for disk free), is used to display information related to file
systems about total space and available space (ex. with du)
• If you want to display all the file system, use -a option.
• To get complete grand total, use –total option
• Use -T option to display file type.
28.fgrep- The fgrep filter is used to search for the fixed-character strings in a file. There
can be multiple files also to be searched. This command is useful when you need to search for
strings which contain lots of regular expression metacharacters, such as “^”, “$”, etc.
29.find- The find command in UNIX is a command line utility for walking a file hierarchy. It
can be used to find files and directories and perform subsequent operations on them. It
supports searching by file, folder, name, creation date, modification date, owner and
permissions
Syntax : $ find [where to start searching from
31.wc- wc stands for word count. As the name implies, it is mainly used for counting
purpose.
• It is used to find out number of lines, word count, byte and characters count in the files
specified in the file arguments.
• By default it displays four-columnar output.
• First column shows number of lines present in a file specified, second column shows
number of words present in the file, third column shows number of characters present in
file and fourth column itself is the file name which are given as argument.
Syntax- wc [OPTION]... [FILE]...
32.sort- SORT command is used to sort a file, arranging the records in a particular order. By
default, the sort command sorts file assuming the contents are ASCII. Using options in sort
command, it can also be used to sort numerically.
• SORT command sorts the contents of a text file, line by line.
• sort is a standard command line program that prints the lines of its input or concatenation
of all files listed in its argument list in sorted order.
• The sort command is a command line utility for sorting lines of text files. It supports sorting
alphabetically, in reverse order, by number, by month and can also remove duplicates.
• The sort command can also sort by items not at the beginning of the line, ignore case
sensitivity and return whether a file is sorted or not. Sorting is done based on one or more
sort keys extracted from each line of input.
33.uniq- The uniq command in Linux is a command line utility that reports or filters out
the repeated lines in a file.In simple words, uniq is the tool that helps to detect the adjacent
duplicate lines and also deletes the duplicate lines. uniq filters out the adjacent matching lines
from the input file(that is required as an argument) and writes the filtered data to the output
file.
34.touch- The touch command is a standard command used in Linux operating system
which is used to create, change and modify timestamps of a file. Basically, there are two
different commands to create a file in the Linux system which is as follows:
• cat command: It is used to create the file with content.
• touch command: It is used to create a file without any content. The file created using touch
command is empty. This command can be used when the user doesn’t have data to store
at the time of file creation.
35. tee- tee command reads the standard input and writes it to both the standard output
and one or more files. The command is named after the T-splitter used in plumbing. It basically
breaks the output of a program so that it can be both displayed and saved in a file. It does both
the tasks simultaneously, copies the result into the specified files or variables and also display
the result.
36.cmp- cmp command in Linux is used to compare the two files byte by byte and helps
you to find out whether the two files are identical or not.
• When cmp is used for comparison between two files, it reports the location of the first
mismatch to the screen if difference is found and if no difference is found i.e the files
compared are identical.
• cmp displays no message and simply returns the prompt if the the files compared are
identical.
37.diff- diff stands for difference. This command is used to display the differences in the
files by comparing the files line by line. Unlike its fellow members, cmp and comm, it tells us
which lines in one file have is to be changed to make the two files identical.
38.ln- The ln command is used to create links between files. Before going into the
application of the ln command in detail, please refer the below link for a clear understanding of
the hard link and soft link in Linux. Hard and Soft Links in Linux
39. ln -s -Soft link (ex. With ln)
40.,41. tar,untar- The Linux ‘tar’ stands for tape archive, is used to create Archive and
extract the Archive files. tar command in Linux is one of the important command which provides
archiving functionality in Linux. We can use Linux tar command to create compressed or
uncompressed Archive files and also maintain and modify them.
Tar: tar -cvf/home/archive.tar
Untar : tar -xvf/home/archive.tar
42.zip: Package and compress (archive) files
Syntax: $ zip -r [options]; $zip -r original.zip zip