0% found this document useful (0 votes)
39 views9 pages

Linux Commands

The whoami, cmp, rm, mount, touch, watch, mkdir, cat, and ifconfig commands in Linux were described. Whoami displays the logged-in username. Cmp compares two files byte by byte. Rm removes files. Mount attaches filesystems to the directory tree. Touch changes file timestamps. Watch runs a command repeatedly. Mkdir creates directories. Cat displays and concatenates file contents. Ifconfig configures network interfaces.

Uploaded by

Jbr Raheem
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views9 pages

Linux Commands

The whoami, cmp, rm, mount, touch, watch, mkdir, cat, and ifconfig commands in Linux were described. Whoami displays the logged-in username. Cmp compares two files byte by byte. Rm removes files. Mount attaches filesystems to the directory tree. Touch changes file timestamps. Watch runs a command repeatedly. Mkdir creates directories. Cat displays and concatenates file contents. Ifconfig configures network interfaces.

Uploaded by

Jbr Raheem
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

LINUX COMMANDS

whoami command:
what :-
whoami command allows linux users to see the currently
logged -in user.
When :-
Running whoami command without any options,the
output shows the name of the currently logged-in user.
Where :-
Whoami command is used when user have more than two
account,then user wants to know which account is in active
Example:-
 Sudo whoami
raheem
Why :-
When you have more than one account,use whoami to
verify the username after switching to a different account.
How :-
Whoami command comes with two following options:
 --help -shows a help message and exits.
 --version -shows the version information and exits.
cmp command :-
What :-
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 :-
 To do comparison between two files.
 When cmp is used for comparison between two files,it
reports the location of the first mismatch to the screen
if different is found and if difference is found
Where :-
$cmp file1.txt file2.txt
If the files are not identical: the output of the above command
will be :
$cmp file1.txt file2.txt
file1.txt file2.txt differ : byte 9,line 2
why :-
when there is two identical files at this time we will use the
cmp command to compare those files byte by byte.
How :-
1. -b (print-bytes) : if you want cmp displays the different
bytes in the output when used with -b option.
2. -i : this option is very much similar to the above -i
option but with the different that now it allows us to
input the number of bytes we want to skip
rm command :-
what:-
rm command removes the entries for a specified file,group
of files ,or certain select files from a list within a directory.
When :-
rm command is used to remove the a files with the two
different names.by default ,it does not remove directories
where :-
when there is a file in directory with two different names
example:-
$ls
a.txt b.txt c.txt d.txt
$rm b.txt
a.txt c.txt d.txt
why :-
when there is a same file has two different then we can use
the rm to remove the existing file.
How :-
 -f (force deletion) : rm prompts for confirmation
removal if a file is write protected
 -r(recursive) : with -r or -R option rm command
performs a tree-walk and will delete all the files and
sub-directories recursively of the parent directory
 -version :it is used to knom th version of rm.
mount command :-
what:-
mount command is used to mount the filesystem found on
a device to big tree structure rooted at ‘/’.
When:-
There is need of mount the filesystem in devices then the
mount command is used.
Where:-
 It displays information about the file system mounted.
$ sudo mount -l -t ext4
/dev/sda3 on/ type ext4 (rw,relatime,errors=remount-
ro,data=ordered)
/dev/sda4 on/media/vivek type ext4
(rw,relatime,data=ordered)
/dev/sda5 on/media/ vivek type ext4
(rw,relatime,data=ordered)
Why :-
If the filesystem is needed to mount with the directory or
device the mount is used,
How:-
 l : list all the filesystem mounted yet.
 h : displays the options for command.
 a : mounts all devices described ar/etc/fstab
 t : type of filesystem devices used uses.
 r :read-only mode mounted.
touch command:-
what:-
touch command is the easiest way to create new,empty
files.
It is also used to change the timestamps on existing files and
directories.
When :-
When we change,create and modify timestamp of a file it
will be used.
Where :-
user@ubuntu:~/Desktop$ X touch file1 file2 file3
user@ubuntu:~/Desktop$ ls
abc~ clientC.c~ file1 file2 file3 serverC
clientC.c~ q10.l~ server.c~
why :-
The touch command updates the access and modification
times of each file specified by the File parameter of each
directory specifies by the direction parameter.
How :-
 touch -m file1 : It can modify the last modification time
only.
 touch -a file1 : It can change the access time only.
 touch -d "2019-06-15 20:40" file1 : It will change the
date and time for both modify and access time.
watch command :-
what :-
Watch command in Linux will repeatedly run command for
you and its offer some very useful options.
When :-
If we are waiting for someone to log into or out of a
system,we could use the watch command to let you know when
they do.Every ten seconds ouyput would be displayed.
Where :-
watch -n 10 date, the watch command will first clear the
screen and run the date command right away.After that,it will
run the command every 10 seconds until you stop.
Why :-
The watch command allow you to rerun command in a loop
until we stop it or run into a condition that stops the looping for
you.
How :-
 -d: this option highlights the differences between
successive updates.
 -n: This option will specify updates interval.The command
will not be going to allow quicker than the 0.1-second
interval,in which the smaller values are getting converted.
 -p:This option make watch attempt to run command every
interval seconds.
mkdir command:-
what :-
Use the mkdir command to create one or more directories
specified by the Directory parameter.

When :-
To make a new directory Use the mkdir command also set
permissions,create multiple directories at once and much more.

Where:-
$mkdir name1
$ls
name1

why:-
Directories are used to help you organize your files.

How:-
 -p :no error if existing,make parent directories as
needed.
 -v:print a message for each created directory.
 --help:display this help and exit.
cat command :-
what :-
cat command allows us to create single or multiple files,
view content of a file, concatenate files and redirect output in
terminal or files.
When :-
Cat(concatenate) command is very frequently used in Linux.
It reads data from the file and gives their content as output. It
helps us to create, view, concatenate files.
Where :-
To create a file to store the content.
Why :-
It can be used to display the content of a file, copy content
from one file to another, concatenate the contents of multiple
files, display the line number, display $ at the end of the line.

How :-
 cat > [fileName] : To create a file.
 cat [oldfile] > [newfile] : To copy content from older
to new file.
 cat -n/cat -b [fileName] :To display line numbers.
 cat -e [fileName] : To display $ character at the end of
each line.
Ifconfig command :-
What :-
The ifconfig command is used for displaying current
network configuration information, setting up an
ip address, netmask, or broadcast address to a network
interface, creating an alias for the network
interface, setting up hardware address, and enable or disable
network interfaces.
When :-
It is used at the boot time to set up the interfaces as
necessary.
Where :-

You might also like