Basic Unix Commands
1.ls -l for listing the files as well as directories those
are kept in the particular working directory
syntax: #ls -l
2.ls -la same as 'ls -l'but by this command we can also see
the hiden files.
syntax: #ls -la
3.ls -li same as 'ls -la' but it will also shows us the inode
number of each and every file
syntax: #ls -li
4.ls by this command we can see only file name nothing
else
syntax: #ls
5.clear it will clear the screen(short cut ctl+l)
syntax: #clear
6.exit to end a current session as well current terminal
logging
syntax:$exit
7.touch to create a new empty file
syntax: $touch
8.cd to change the working/present directory
syntax: $cd /home/mango
where '/home/mango' is the desired directory to be
change from '/root'
9.cat to view the contents of a file and it is also used for creating a new file with some contents
syntax: $cat to view
file contents
$cat > newfilename
enter,then you can write something in the file and
then to save the file contents press clt+d then enter
10.mkdir to make a new directory
syntax: $mkdir newdirname
you can also create a directory at your desired path without changing your present working directory
syntax: $mkdir /home/mango/newdirname
11.rm to remove a empty file
syntax: $rm filename
12.rmdir to remove a empty directory
syntax: $rmdir directoryname
13.rm [-i/-r/-f] to remove a directory with its subdirectories as well as its files that is to remove a directory which already contains some files in it
syntax: $rm –i directory/filename
-i stands for interactively
-r stands for recursively
-f stands for forcefully
14.cp to copy something in a destination file or directory
syntax: $cp sourcepath destinationpath
example: $cp /home/mango/webmin.rpm /root/abcd
in this example the webmin.rpm file will be copied in /root/abcd directory
15.mv to move one file or directory from one place to another place, it is also used for renaming adirectory or file
syntax: $mv source destination
$mv oldfilename newfilename [to change the file name]
16.man to view the mannual page of commands for syntax
syntax: $man commandname
17.info to view the information about any command
syntax: $mkdir info
18.--help to view the help doccuments of a command
syntax: $commandname --help
19.dir to view the subdirectories and files under the directory
syntax: $dir
20.su - to become a super user
syntax: [mango@localhost mango]$su -
output wil be [root@localhost root#]
21.who by this command you can see the user name and their ip addresses who have logged in on your server
syntax: $who
22.whoami this command shows your current logged in terminal user name
syntax: $whoami
23.who am i this command shows you the logged in terminal number and user name and more detailed information
syntax: $who am i
24.pwd to view the present working directory
syntax: $pwd
25.rpm -ivh to install a rpm package
syntax: $rpm –ivh packagename.rpm
rpm stands for 'redhat package manager'
-i stands for install
-v stands for verbose mode
-h stands for with hash sign(#)
26.rpm -q to query about any rpm package
syntax: $rpm -q package name
27.rpm -e to uninstall a rpm package
syntax: $rpm -e package
28.find / -name to find any file or directory in linux file system
syntax: $find / -name filename
29.su username to switch from one user to another users home directory
syntax: $su mango
output will be [mango@localhost root]#cd [mango@localhost mango]#
30.su - username to switch from one user to another user users home directory directly
syntax: $su - mango
31.useradd to create a new user
syntax: $useradd username
32.passwd to give a password of a user
syntax: $passwd madhava
output will be give a password for user madhava:(here you have to type a password for madhava user) confirm password:(again type the same password)
33.userdel to remove a user from linux
syntax: $userdel tarun
34.groupadd to add a new group
syntax: $groupadd groupname
35.gruopdel to delete a group
syntax: $groupdel groupname
36.chown to change the ownership of a file or directory
syntax: $chown ownername filename
example:$ls -l
output:
drwxrw-rw- 2 root root 4096 Mar 11 12:03 abcd
(permission) (own) (group own)(size) (name)
$chown tarun /abcd
in this example /abcd directory owner will be change to madhava user effect
$ls -l
drwxrw-rw- 2 madhava root 4096 Mar 11 12:03 abcd
37.chgrp to change the group ownership of a file or directory
syntax: $chgrp newgroupownername filename
example:$ls -l
drwxrw-rw- 2 madhava root 4096 Mar 11 12:03 abcd
$chgrp madhava /abcd
effect:$ls -l
drwxrw-rw- 2 madhava madhava 4096 Mar 11 12:03 abcd
38.chmod to change the permission of a file or directory
drwxrw-rw- 2 root root 4096 Mar 11 12:03 abcd
(permission) (ownr) (grpownr) (size) (name) IN
OCTAL VALUE:d stands for directiry READ=4
r stands for read only permission WRITE=2
w stands for write only permission
EXECUTE=1
x stands for execute only permission
drwxrw-rw- FIRST OCTET FOR DENOTING THE DIRECTORY OR FILE OR LINK FILE ETC.
SECOND THREE OCTET FOR USER OR OWNER PERMISSION (rwx OR 7 IN OCTAL VALUE) THIRD THREE OCTET FOR GROUP PERMISSION (rw- OR 6 IN OCTAL VALUE)
FORTH THREE OCTET FOR OTHERS PERMISSION (rw- OR 6 IN OCTAL VALUE)
SYNTAX: $chmod value fileordirectoryname
example: $ls -l
drwxrw-rw- 2 madhava root 4096 Mar 11 12:03 abcd
$chmod 402 /abcd
$ls -l
drw-----w- 2 madhava madhava 4096 Mar 11 12:03 abcd
40.usermod to modify the user profile
synatx: [root@localhost root]#usermod –parameter groupname username
41.vi to edit a file.
synatx: $vi filename/absolute_path/relative_path
42.ipconfig to get information about Ethernet card (for WINDOWS).
synatx: $ipconfig /all
43.ifconfig to get information about Ethernet card (for LINUX).
synatx: $ifconfig
44.ping to check whether two machines are connected or not.
synatx: $ping
45.telnet to login to the server(in which LINUX operating system is running) from a remote machine.
synatx: $telnet
1.ls -l for listing the files as well as directories those
are kept in the particular working directory
syntax: #ls -l
2.ls -la same as 'ls -l'but by this command we can also see
the hiden files.
syntax: #ls -la
3.ls -li same as 'ls -la' but it will also shows us the inode
number of each and every file
syntax: #ls -li
4.ls by this command we can see only file name nothing
else
syntax: #ls
5.clear it will clear the screen(short cut ctl+l)
syntax: #clear
6.exit to end a current session as well current terminal
logging
syntax:$exit
7.touch to create a new empty file
syntax: $touch
8.cd to change the working/present directory
syntax: $cd /home/mango
where '/home/mango' is the desired directory to be
change from '/root'
9.cat to view the contents of a file and it is also used for creating a new file with some contents
syntax: $cat to view
file contents
$cat > newfilename
enter,then you can write something in the file and
then to save the file contents press clt+d then enter
10.mkdir to make a new directory
syntax: $mkdir newdirname
you can also create a directory at your desired path without changing your present working directory
syntax: $mkdir /home/mango/newdirname
11.rm to remove a empty file
syntax: $rm filename
12.rmdir to remove a empty directory
syntax: $rmdir directoryname
13.rm [-i/-r/-f] to remove a directory with its subdirectories as well as its files that is to remove a directory which already contains some files in it
syntax: $rm –i directory/filename
-i stands for interactively
-r stands for recursively
-f stands for forcefully
14.cp to copy something in a destination file or directory
syntax: $cp sourcepath destinationpath
example: $cp /home/mango/webmin.rpm /root/abcd
in this example the webmin.rpm file will be copied in /root/abcd directory
15.mv to move one file or directory from one place to another place, it is also used for renaming adirectory or file
syntax: $mv source destination
$mv oldfilename newfilename [to change the file name]
16.man to view the mannual page of commands for syntax
syntax: $man commandname
17.info to view the information about any command
syntax: $mkdir info
18.--help to view the help doccuments of a command
syntax: $commandname --help
19.dir to view the subdirectories and files under the directory
syntax: $dir
20.su - to become a super user
syntax: [mango@localhost mango]$su -
output wil be [root@localhost root#]
21.who by this command you can see the user name and their ip addresses who have logged in on your server
syntax: $who
22.whoami this command shows your current logged in terminal user name
syntax: $whoami
23.who am i this command shows you the logged in terminal number and user name and more detailed information
syntax: $who am i
24.pwd to view the present working directory
syntax: $pwd
25.rpm -ivh to install a rpm package
syntax: $rpm –ivh packagename.rpm
rpm stands for 'redhat package manager'
-i stands for install
-v stands for verbose mode
-h stands for with hash sign(#)
26.rpm -q to query about any rpm package
syntax: $rpm -q package name
27.rpm -e to uninstall a rpm package
syntax: $rpm -e package
28.find / -name to find any file or directory in linux file system
syntax: $find / -name filename
29.su username to switch from one user to another users home directory
syntax: $su mango
output will be [mango@localhost root]#cd [mango@localhost mango]#
30.su - username to switch from one user to another user users home directory directly
syntax: $su - mango
31.useradd to create a new user
syntax: $useradd username
32.passwd to give a password of a user
syntax: $passwd madhava
output will be give a password for user madhava:(here you have to type a password for madhava user) confirm password:(again type the same password)
33.userdel to remove a user from linux
syntax: $userdel tarun
34.groupadd to add a new group
syntax: $groupadd groupname
35.gruopdel to delete a group
syntax: $groupdel groupname
36.chown to change the ownership of a file or directory
syntax: $chown ownername filename
example:$ls -l
output:
drwxrw-rw- 2 root root 4096 Mar 11 12:03 abcd
(permission) (own) (group own)(size) (name)
$chown tarun /abcd
in this example /abcd directory owner will be change to madhava user effect
$ls -l
drwxrw-rw- 2 madhava root 4096 Mar 11 12:03 abcd
37.chgrp to change the group ownership of a file or directory
syntax: $chgrp newgroupownername filename
example:$ls -l
drwxrw-rw- 2 madhava root 4096 Mar 11 12:03 abcd
$chgrp madhava /abcd
effect:$ls -l
drwxrw-rw- 2 madhava madhava 4096 Mar 11 12:03 abcd
38.chmod to change the permission of a file or directory
drwxrw-rw- 2 root root 4096 Mar 11 12:03 abcd
(permission) (ownr) (grpownr) (size) (name) IN
OCTAL VALUE:d stands for directiry READ=4
r stands for read only permission WRITE=2
w stands for write only permission
EXECUTE=1
x stands for execute only permission
drwxrw-rw- FIRST OCTET FOR DENOTING THE DIRECTORY OR FILE OR LINK FILE ETC.
SECOND THREE OCTET FOR USER OR OWNER PERMISSION (rwx OR 7 IN OCTAL VALUE) THIRD THREE OCTET FOR GROUP PERMISSION (rw- OR 6 IN OCTAL VALUE)
FORTH THREE OCTET FOR OTHERS PERMISSION (rw- OR 6 IN OCTAL VALUE)
SYNTAX: $chmod value fileordirectoryname
example: $ls -l
drwxrw-rw- 2 madhava root 4096 Mar 11 12:03 abcd
$chmod 402 /abcd
$ls -l
drw-----w- 2 madhava madhava 4096 Mar 11 12:03 abcd
40.usermod to modify the user profile
synatx: [root@localhost root]#usermod –parameter groupname username
41.vi to edit a file.
synatx: $vi filename/absolute_path/relative_path
42.ipconfig to get information about Ethernet card (for WINDOWS).
synatx: $ipconfig /all
43.ifconfig to get information about Ethernet card (for LINUX).
synatx: $ifconfig
44.ping to check whether two machines are connected or not.
synatx: $ping
45.telnet to login to the server(in which LINUX operating system is running) from a remote machine.
synatx: $telnet
46.init to change the Run Level.
synatx: $init run_level
run_level: 0 --> halt (Do NOT set initdefault to this)
1 --> Single user mode
2 --> Multiuser, without NFS(The same as 3,
if you do not have networking)
3 --> full multiuser mode
4 --> unused
5 --> for graphics mode(X11)
6 --> reboot (Do NOT set init default to this)
47.shutdown to halt/restart the machine
syntax: $shutdown -h/-r time
-h --> for halt
-r --> for restart
run_level: 0 --> halt (Do NOT set initdefault to this)
1 --> Single user mode
2 --> Multiuser, without NFS(The same as 3,
if you do not have networking)
3 --> full multiuser mode
4 --> unused
5 --> for graphics mode(X11)
6 --> reboot (Do NOT set init default to this)
47.shutdown to halt/restart the machine
syntax: $shutdown -h/-r time
-h --> for halt
-r --> for restart
No comments:
Post a Comment