Os Commands 21bce1844
Os Commands 21bce1844
Directory:
Command: pwd
Description: The above command writes the current working directory or present working directory to the
standard output from root directory each directory is separated by slash(“/”).
Example:
If we are working in a directory called 21BCE1844 in desktop directory then pwd writes
/home/Desktop/21BCE1844
Description: The above command creates directories in the current working directory. To create multiple
directories names of directories should be separated by space.
Example:
If we are working in a directory called 21BCE1844 if we use mkdir new1 new2 command then two new
directories name new1 and new2 are created in 21BCE1844 directory
Description: The above command deletes the directory with the given name in current working directory. To
delete multiple directories names of directories should be separated by space.
Example:
If we are working in a directory called 21BCE1844 if we use rmdir new1 new2 command then we can’t find
two directories named new1 and new2 in 21BCE5526 directory
Command: cd <name>
Description: cd is known as change directory. With the help of cd we can change the active directory we are
working cd changes the active directory to the given directory name.
Example:
If the active directory is Desktop then if we use cd 21BCE1844 then active directory changes to 21BCE1844
Command: cd /
Description: The above command is used to return to root directory. Regardless of currently active or working
directory when this command runs we return to root directory.
Example:
Command: cd ..
Description: The above command is used to return to previously working directory i.e the directory which is
containing the current directory.
Example:
If we are in the address /home/Desktop/21BCE1844 then if we use cd .. command the current active directory
changes to /home/Desktop.
Output:
File:
Command: cat><name>
Description: The above command is used to create a new file with the given name. it creates an editable file
and also asks user to get input , save it in the file until host + D is entered.
Example: if we use the command cat>f2.txt then it creates a text file named f2 and it takes content until host+d
is clicked.
Description: The above command is used to display the content of the file with given name the content of
given file is written in standard output.
Example:
Example: If we use cp f2.txt f3.txt then the content of f2 which is “ASHISH CHAITANYA” is written in f3.txt
and the content in f3.txt is deleted.
Description: The above command is used to copy the content of one file to another file. The source is the name
of source file and destination is the name of destination where the content should be overwritten. Before
overwriting it gives us a warning message.
Example: If we use cp f2.txt f3.txt then the warning message appears if enter Y then content of f2 which is
“ASHISH CHAITANYA” is written in f3.txt and the content in f3.txt is deleted.
Description: The above command is used to copy the content of one folder to another folder. The source is the
name of source file and destination is the name of destination where the content should be copied. It copies
everything from source to destination directory
Example: If we use cp -r new1 new2 then files in new1 which are f3.txt,f2.txt copied into new2 directory
Description: The above command is used to display the given content of the file with the given name and it
will give the line number in the std output.
Example: If we use cat -n f3.txt as there is only one line in f3.txt which is “ASHISH CHAITANYA” the std
output will be “1. ASHISH CHAITANYA”.
Description: The above command is used to copy the content of one file to another file. The source is the name
of source file and destination is the name of destination where the content should be overwritten. After copying
the source file will be deleted if there is no file with destination name then the source file is renamed as
destination file.
Example: If we use mv f2.txt f3.txt then the content of f2 which is “ASHISH CHAITANYA” is written in
f3.txt and the file f2.txt is deleted.
Description: The above command is used to copy the files with the names and move them into given directory
name at end. After copying the source files i.e the files with the names will be deleted.
Example: If we use mv f2.txt f5.txt new2 then new2 directory content is f2.txt and f5.txt where as previous
directory of f2 and f5 is going to be empty.
Command: rm <name>
Description: The above command is used to file with given name.
Command: rm *
Description: The above command is used to delete the all files in the current working directory.
Description: The above command is used to delete the all files in the current working directory even with its
sub directories
Command: rm -f*
Description: The above command is used to delete the all files in the current working directory even though
they are write protected.
Output:
Filters and Pipes:
Description: The above command is used to display the first 10 lines of file with the given name. when this
command is called the first 10 lines in file will be written to standard output.
Description: The above command is used to display the last 10 lines of file with the given name. when this
command is called the last 10 lines in file will be written to standard output.
Description: The above command is used to highlight the pattern given in the content given in the file. The
given pattern is displayed in a separate color than the content with only the lines which contain the given
pattern.
Example:
If the file content is 21BCE1844 ASHISH CHAITANYA and name is simple.txt. then if we use the command
grep raj simple.txt then the output is 21BCE1844 ASHISH CHAITANYA.
Output:
List
Command: ls -a
Description: The above command is used to display all the files in directory even it displays the hidden files.
The command writes the names of files in standard output. The hidden file is displayed with a dot at starting
point.
Example:
In the home directory bashrc is a hidden file when the above command is used the name of hidden file bashrc is
also appears in standard output as .bashrc .
Command: ls -d */
Description: The above command is used to write the names only directories available in currently active
directory in standard output.
Example:
Home directory has sub directories like desktop, videos, pictures. The above command writes desktop/ videos/
pictures/
Command: ls -m
Description: The above command writes the names of files and folders inside the currently active directory by
separating with commas in standard output.
Example:
Home directory has sub directories like desktop, videos, pictures. The above command writes desktop, videos,
pictures.
Command: ls -p
Description: The above command is used to display the directory name appended with a single slash if it is
containing sub directories or files in it.
Example:
Home directory has sub directories like desktop, videos, pictures. The above command writes desktop/ videos/
pictures/.
Command: ls -r
Description: The above command is used to write the directory names in the currently active directory sorted in
reversed alphabetical order in standard output.
Example:
Home directory has sub directories like desktop, videos, pictures. The above command writes videos pictures
desktop.
Command: ls -t
Description: The above command is used to write the directory names in the currently active directory sorted in
latest modified order in standard output.
Example:
Home directory has sub directories like desktop, videos, pictures. The above command writes desktop/ videos/
pictures/.
Command: ls -R
Description: The above command is used to write the directory names and files with their sub directories down
to last file in the currently active directory in standard output.
Example:
Home directory has sub directories like desktop, videos, pictures. The above command writes ./desktop:
21BCE1844 new
./videos :
./pictures:
Output:
ECHO:
Command: echo <text>
Description: The above command is used to write the given text in standard output.
Description: The above command is used to write the address of user’s home directory in standard output.
Output:
Banner:
Description: The above command is used to write the given text in standard output using the symbol #.
Output:
Command: tty
Description: The above command is used to write the address of file in which terminal is stored to standard
output.
Example: if we use tty and terminal is stored in the address /dev/pts/3 then the output is /dev/pts/3.
Output:
Command: bc
Description: The above command is used to generate a basic calculator we can perform basic arithmetic
operations using the calculator we need to write the arithmetic equation in standard input and the result is
displayed in standard output when enter is pressed. Ctrl+d is used to exit from this calculator.
Example: if we use bc and then we enter 5+3 and press enter the standard output written is 8.
Output:
Calendar
Description: The above command is used to write the entire calendar of the given year number in standard
output.
Description: The above command is used to write the entire calendar of the given year of particular month
number in standard output.
Example: if we use cal 11 2003 we get the entire calendar of November month in 2003.
Output:
Clear
Command: clear
Description: The above command is used to clear all the previous commands from standard output.
Output:
WHO
Command: who
Description: The above command is used to write the details of users who are currently logged in. In the
standard output.
Example: if we use who command in a linux system has 2 users then then it displays their name, logged in time
etc.
Command: who -H
Description: The above command is used to write the details of users who are currently logged in with header
files. In the standard output.
Example: if we use who -H command in a linux system has 2 users then then it displays their name, logged in
time etc.
Command: who -b
Description: The above command is used to write the last booting time of system in the standard output.
Example: if we use who -b command in a linux system then we get when we last logged in into system.
Command: whoami
Description: The above command is used to write the details of user who is currently logged in. In the standard
output.
Example: if we use who command in a linux system with user name ASHISH CHAITANYA then the output is
ASHISH CHAITANYA.
Output:
Manual
Description: The above command is used to get the manual about the text we entered if it is a valid command
and it doesn’t take any arguments then we get the details of the command else if it is not a command and it is
some random text then we get No manual entry for the text we entered.
Example: if we use man hi we get “No manual entry for hi” if we use man ls we get the details of usage of ls
command.
Output:
Date:
Description: The above command is used to write the today’s day in standard output in abbreviated form in
standard output.
Example: if we use date +%a command then we get “tue” as today is tuesday.
Description: The above command is used to write the today’s day in standard output in a full form in standard
output.
Example: if we use date +%A command then we get “tuesdsay” as today is tuesday.
Example: if we use date +%b command then we get “dec” as this month is December.
Description: The above command is used to write the present month in standard output in full form in standard
output.
Example: if we use date +%B command then we get “december” as this month is December.
Description: The above command is used to write the day, date, month, year, time and meridian in standard
output in abbreviated form in standard output.
Example: if we use date +%c command then we get “Tuesday 13 December 2022 11:34:03 PM”.
Description: The above command is used to write the present century in standard output in standard output.
Example: if we use date +%C command then we get “20” as this year starts with 20.
Description: The above command is used to write the present day’s date in standard output.
Example: if we use date +%d command then we get “13” as today’s date is 13.
Description: The above command is used to write the present day’s date, month and year in standard output.
Example: if we use date +%D command then we get “12/13/22” as today’s date is 13 th December 2022.
Description: The above command is used to write the present day’s date in standard output.
Example: if we use date +%C command then we get “13” as today’s date is 13.
Description: The above command is used to write the present month in abbreviated form in standard output.
Example: if we use date +%h command then we get “dec” as this month is December.
Description: The above command is used to write the present hour in standard output.
Example: if we use date +%H command then we get “23” as present time is 23:00.
Command: date +%m
Description: The above command is used to write the number of present month in standard output.
Example: if we use date +%m command then we get “12” as this month is December.
Description: The above command is used to write the present minute in standard output.
Example: if we use date +%M command then we get “36” as time is 23:36.
Description: The above command is used to write the present meridian in lowercase letters in standard output.
Example: if we use date +%P command then we get “pm” as it is 23:00 pm now.
Description: The above command is used to write the present meridian in uppercase letters in standard output.
Example: if we use date +%p command then we get “PM” as it is 23:00 pm now.
Description: The above command is used to write the present seconds in standard output.
Example: if we use date +%S command then we get “30” as it is 23:36:30am now.
Description: The above command is used to write the present time in HH:MM:SS format in standard output.
Example: if we use date +%T command then we get “23:36:30” as it is 23:36:30 pm now.
Description: The above command is used to write the last 2 digits of present year in standard output.
Example: if we use date +%y command then we get “22” as it is 2022 now.
Description: The above command is used to write the present year in standard output.
Example: if we use date +%Y command then we get “2022” as it is 2022 now.
Description: The above command is used to write the time zone in standard output.
Example: if we use date +%Z command then we get “IST” as we live in India now.
Example: if we use date +%y command then we get “2022” as it is 2022 now.
Description: The above command is used to write the present time in HH-MM-SS format in standard output.
Example: if we use date +%T command then we get “23-36-30” as it is 23:36:30 pm now.
Output:
Manipulation:
Description: The above command is used to write the complete name of the terminal in standard output.
Description: The above command is used to write the complete name of the terminal in standard output with
background colour as green and letters as black.
Description: The above command is used to shift the pointer to a designated location
Description: The above command is used to write the number of columns available in terminal in standard
output.
Output: