Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Tuesday, September 11, 2012

Basic Linux Commands for Developers


Linux is a kernal but it commonly known as Operating System. Linux provide two interfaces: 
a. Command Line Interface (CLI) 
b. Graphical User Interface (GUI) 

In Command Line Interface, we generally use commands. Here is a collection of basic linux commands. 


Basic Linux Commands for Developers
ls -l for listing the files as well as directories those are kept in the particular working directory syntax [gaurav@localhost ~] $ ls -l

ls -la same as 'ls -l'but by this command we can also see the hiden files. 
syntax [gaurav@localhost ~] $ ls -la

ls -li same as 'ls -la' but it will also shows us the inode number of each and every file 
syntax [gaurav@localhost ~] $ ls -li

ls by this command we can see only file name nothing else 
syntax [gaurav@localhost ~] $ ls

clear it will clear the screen(short cut ctl+l) 
syntax [gaurav@localhost ~] $ clear

exit to end a current session as well current terminal logging 
syntax [gaurav@localhost ~] $ exit

touch to create a new empty file 
syntax [gaurav@localhost ~] $ touch

cd to change the working/present directory 
syntax [gaurav@localhost ~] $ cd /home/mango where '/home/mango' is the desired directory to be change from '/root'

cat to view the contents of a file and it is also used for creating a new file with some contents syntax [gaurav@localhost ~] $ cat to view file contents [gaurav@localhost ~] $ cat > newfilename enter,then you can write something in the file and then to save the file contents press clt+d then enter

mkdir to make a new directory 
syntax  [gaurav@localhost ~] $ mkdir newdirname 
you can also create a directory at your desired path without changing your present working directory 
syntax  [gaurav@localhost ~] $ mkdir /home/mango/newdirname

rm to remove a empty file 
syntax  [gaurav@localhost ~] $ rm filename

rmdir to remove a empty directory 
syntax  [gaurav@localhost ~] $ rmdir directoryname

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  [gaurav@localhost ~] $ rm -i directory/filename -i stands for interactively -r stands for recursively -f stands for forcefully

cp to copy something in a destination file or directory 
syntax  [gaurav@localhost ~] $ cp sourcepath destinationpath example: [gaurav@localhost ~] $ cp /home/mango/webmin.rpm /root/abcd in this example the webmin.rpm file will be copied in /root/abcd directory

mv to move one file or directory from one place to another place, it is also used for renaming adirectory or file.
syntax  [gaurav@localhost ~] $ mv source destination [gaurav@localhost ~] $ mv oldfilename newfilename [to change the file name]

man to view the mannual page of commands for syntax 
syntax  [gaurav@localhost ~] $ man commandname

info to view the information about any command 
syntax  [gaurav@localhost ~] $ mkdir info

--help to view the help documents of a command 
syntax  [gaurav@localhost ~] $ commandname --help

dir to view the subdirectories and files under the directory 
syntax  [gaurav@localhost ~] $ dir

who by this command you can see the user name and their ip addresses who have loged in on your server syntax  [gaurav@localhost ~] $ who

whoami this command shows your current logged in terminal user name 
syntax  [gaurav@localhost ~] $ whoami

who am i this command shows you the logged in terminal number and user name and more detailed information
syntax  [gaurav@localhost ~] $ who am i

pwd to view the present working directory 
syntax  [gaurav@localhost ~] $ pwd

rpm -ivh to intall a rpm package 
syntax  [gaurav@localhost ~] $ 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(#)

rpm -q to querry about any rpm package 
syntax  [gaurav@localhost ~] $ rpm -q packagename

rpm -e to uninstall a rpm package 
syntax  [gaurav@localhost ~] $ rpm -e package

find / -name to find any file or directory in linux file system 
syntax  [gaurav@localhost ~] $ find / -name filename

su username to switch from one user to another users home directory 
syntax  [gaurav@localhost ~] $ su mango output will be [mango@nettech root]#cd [mango@nettech mango]#

su - username to switch from one user to another user users home directory directly 
syntax  [gaurav@localhost ~] $ su - mango

useradd to create a new user 
syntax  [gaurav@localhost ~] $ useradd username

passwd to give a password of a user 
syntax  [gaurav@localhost ~] $ passwd tarun output will be give a password for user tarun:(here you have to type a password for tarun user) confirm password:(again type the same password)

userdel to remove a user from linux 
syntax  [gaurav@localhost ~] $ userdel tarun

groupadd to add a new group 
syntax  [gaurav@localhost ~] $ groupadd groupname

gruopdel to delete a group 
syntax  [gaurav@localhost ~] $ groupdel groupname

chown to change the ownership of a file or directory 
syntax  [gaurav@localhost ~] $ chown ownername filename

chgrp to change the group ownership of a file or directory 
syntax  [root@nettec root]#chgrp newgroupownername filename

usermod to modify the user profile 
syntax  [gaurav@localhost ~] $ usermod -parameter groupname username


1 comment: