Scroll Top
577, Gold Plaza, Punjab Jewellers, M.G. Road, Opp. Treasure Island Mall

Linux Commands

Linux Commands

  1. ls -l for listing the files as well as directories those are kept in the particular working directory

[root@armourinfosec ~]# ls โ€“l

  1. ls -la same as ‘ls -l’ but by this command we can also see the hidden files

[root@armourinfosec ~]#ls โ€“la

  1. ls -li same as ‘ls -la’ but it will also shows us the inode number of each and every file

[root@armourinfosec ~]#ls โ€“li

  1. ls by this command we can see only file name nothing else

[root@armourinfosec ~]#ls

  1. clear it will clear the screen ( short cut ctl + l )

[root@armourinfosec ~]#clear

  1. exit to end a current session as well current terminal logging

[root@armourinfosec ~]#exit

  1. touch to create a new empty file

[root@armourinfosec ~]#touch myfile.txt

  1. cd to change the working/present directory

[root@armourinfosec ~]#cd /home/sachin

  1. cat to view the contents of a file and it is also used for creating a new file with some contents

[root@armourinfosec ~]#cat <file name> to view file contents

[root@armourinfosec ~]#cat > newfilename enter, then you can write something in the file and then to save the file contents press clt+d then enter

 

  1. mkdir to make a new directory

[root@armourinfosec ~]#mkdir newdirname

you can also create a directory at your desired path without changing your present working directory

[root@armourinfosec ~]#mkdir /home/sachin/newdirname

  1. rm to remove a empty file

[root@armourinfosec ~]#rm filename

  1. rmdir to remove a empty directory

[root@armourinfosec ~]#rmdir directoryname

  1. 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

[root@armourinfosec ~]#rm -i directory/filename

-i stands for interactively

-r stands for recursively

-f stands for forcefully

  1. cp to copy something in a destination file or directory

[root@armourinfosec ~]#cp sourcepath destinationpath

[root@armourinfosec ~]#cp /home/sachin/webmin.rpm /root/abcd

 

in this example the webmin.rpm file will be copied in

/root/abcd directory

  1. mv to move one file or directory from one place to another place, it is also used for renaming adirectory or file

[root@armourinfosec ~]#mv source destination

[root@armourinfosec ~]#mv oldfilename newfilename [to change the file name]

 

  1. man to view the mannual page of commands for syntax

[root@armourinfosec ~]#man commandname

  1. info to view the information about any command

[root@armourinfosec ~]#mkdir info

  1. –help to view the help doccuments of a command

[root@armourinfosec ~]#commandname โ€“help

  1. dir to view the subdirectories and filesn under the directory

[root@armourinfosec ~]#dir

  1. who by this command you can see the user name and their ip addresses who have loged in on your server

[root@armourinfosec ~]#who

  1. whoami this command shows your current logged in terminal user name

[root@armourinfosec ~]#whoami

  1. who am i this command shows you the logged in terminal number and user name and more detailed information

[root@armourinfosec ~]#who am i

  1. pwd to view the present working directory

[root@armourinfosec ~]#pwd

  1. rpm -ivh to intall a rpm package

[root@armourinfosec ~]#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(#)

  1. rpm -q to querry about any rpm package

[root@armourinfosec ~]#rpm -q packagename

  1. rpm -e to uninstall a rpm package

[root@armourinfosec ~]#rpm -e package

  1. find / -name to find any file or directory in linux file system

[root@armourinfosec ~]#find / -name filename

  1. su username to switch from one user to another users home directory

[root@armourinfosec ~]#su sachin

  1. su – username to switch from one user to another user users home directory directly

[root@armourinfosec ~]#su โ€“ sachin

  1. useradd to create a new user

[root@armourinfosec ~]#useradd username

  1. passwd to give a password of a user

[root@armourinfosec ~]#passwd sachin

give a password for user sachin:(here you have to type a password for sachin user) Confirm password:(again type the same password)

  1. userdel to remove a user from linux

[root@armourinfosec ~]#userdel sachin

  1. groupadd to add a new group

[root@armourinfosec ~]#groupadd groupname

  1. gruopdel to delete a group

[root@armourinfosec ~]#groupdel groupname

  1. chown to change the ownership of a file or directory

[root@armourinfosec ~]#chown ownername filename

  1. chgrp to change the group ownership of a file or directory

[root@armourinfosec ~]#chgrp newgroupownername filename

  1. usermod to modify the user profile

[root@ armourinfosec ~]#usermod -parameter groupname username

Leave a comment

Send Comment

WhatsApp us