0% found this document useful (0 votes)
3 views

Linux

Uploaded by

Roshan Choudhari
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Linux

Uploaded by

Roshan Choudhari
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Getting Help

•Don't try to memorize everything!

•Many levels of help


whatis
command –help
man and info
The whatis Command

•Displays short descriptions of commands

•Eg :

# whatis ls
locate
•locate – used for file searching in linux
Search in database.

•Usage:
locate [options] file name

•Eg:-
# locate passwd
# locate –r /passwd$ to find with exact filename

-e – print only file which are present


updatedb – to update database
diff
•diff – used to display the difference in the files by
comparing the file line by line.

•Usage:
diff [options] file1 file2

Symbols
a : Add
c : change
d : delete
•Eg:-
# diff a.txt b.txt
# diff –c a.txt b.txt
diff
•# diff –c a.txt b.txt

# diff –y –w 72 a.txt b.txt


file

•file – used to see the type of file

•Usage:
file [options] filename

•Eg:-
# file passwd
Links
HARD LINKS
1. Hard Links have same inodes number.
2. ls -l command shows all the links with the link column showing the number of
links.
3. Links have actual file contents
4. Removing any link, just reduces the link count but doesn't affect the other
links.
5. You cannot create a Hard Link for a directory.
6. Even if the original file is removed, the link will still show you the contents of
the file.
•ln filename linkname
Symbolic (or Soft) Links

•A symbolic link points to another file


•ls -l displays the link name and the referenced file
•File type: l for symbolic link
•The content of a symbolic link is the name of the file that it
references
•Syntax:
ln -s filename linkname
•Eg: # ln -s /etc/passwd password
# ls -li /etc/passwd password
different inode number
whereis

whereis command is used to find the location of


source/binary file of a command and manuals sections
for a specified file in Linux system.

# whereis ls

ls:/usr/bin/ls /usr/share/man/man1/ls.1.gz /usr/share/man/man1p/ls.1p.gz

# whereis –b ls ------ to see binary files

/usr/bin/ls
Simple Commands

•date - display date and time


•cal - display calendar
•Eg:
# date
# date -s 12/08/2010
# date -s 5:15:30
# cal
# cal 2009
# cal 5 2009
# cal 2009 | more
time

• to execute a command and prints a summary of real-time, user CPU time

and system CPU time spent by executing a command when it terminates.

• ‘real‘ time is the time elapsed wall clock time taken by a command to get

executed, ‘user‘ and ‘sys‘ time are the number of CPU seconds that

command uses in user and kernel mode respectively.

• # time –p sleep 5

real 5.00

user 0.00

sys 0.00
Who

• who - show who is logged on

•Syntax:
who
•Eg: # who
•abc :0 2020-11-05 09:46 (:0)
•user1 pts/0 2020-11-05 13:07 (192.168.81.1)

# who –a will show all login users


Whoami

•whoami - print effective userid

•Syntax:
whoami

•Eg: $ whoami
user1
Finger
command is a user information lookup command which gives details of all the users
logged in.
This tool is generally used by system administrators. It provides details like login name,
user name, idle time, login time, and in some cases their email address even.

•Need to install finger command


# sudo yum install finger

# finger
Login Name Tty Idle Login Time Office Office Phone Host
abc *:0 Nov 5 09:46 (:0)
user1 pts/0 Nov 5 13:07 (192.168.81.1)
pushd command – puts/adds directory paths onto a directory stack (history)
and later allowing you to navigate back to any directory in history.
While you add directories to the stack,
it also echoes what’s existing in history (or “stack”).

$ pushd /var/www/html/
$ pushd ~/Documents/
$ pushd ~/Desktop/
$ pushd /var/log/

popd command – removes a directory from the top of the stack or history.
To list the directory stack, type:
$ popd
tac
• tac – is reverse of cat
•It will print contain of file reverse
•Last line will be first
•Syntax:
# cat f1
ram dbda pune 10
pinky dac pune 60
sam ditiss pune 20

# tac f1
sam ditiss pune 20
pinky dac pune 60
ram dbda pune 10
Reboot
# reboot
# reboot -f
# init 6
# shutdown -r now
# shutdown -r 5

Shutdown

# poweroff
# halt
# init 0
# shutdown -h now
# shutdown -h 5

You might also like