Linux
Linux
•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
•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
•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
# whereis ls
/usr/bin/ls
Simple Commands
• ‘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
• # time –p sleep 5
real 5.00
user 0.00
sys 0.00
Who
•Syntax:
who
•Eg: # who
•abc :0 2020-11-05 09:46 (:0)
•user1 pts/0 2020-11-05 13:07 (192.168.81.1)
•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.
# 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