
LINUX COMMANDS
- df –h: It is showing filesystems,size,used,available,use%,mounted
(which file we want see we need to be in that path and execute this command )
- -T : display the type of file system
- -t ext3: it will display the only ext3 filesystems
- cd : change of directory
- / : go to root
- dmesg : hardware information
- uptime : display the load average
- pwd : present working directory
- who : it display the how many numbers login
- ami : current user working
- am i(#tty) : current terminal with user
- -b : last reboot time
- -r : it display the run level
- ls : list of directories&files
- -l : to find out which is directory and which is file “D” it indicate the directory, “-“ which indicate the file
- Touch filename : To create empty file
- Mkdir directoryname : to create directory
- dir1 dir2 dir3 : successive directories
- -p directoryname : create directories progressively
- cat filename : open the file
- >filename : create text in file
- >>filename: upend the text
- f1 f2 f3 >f4: copy the text from previous file to the new file
- f1 f2 f3.. : open the file in progressively
- cd.. : go to one step back
- find /var –xdev –type f –ls |sort –rn –key=7 |head -10:
find command
- wc –l : word count
- cp sourcepath targetpath : copy from root
- filename targetpath : copy from source
- sourcepath : copy from target
- -r sourcepath targetpath : copy the directory from root
- -r sourcepath/* targetpath : copy the all files&sub directories from directory
- Filename filename.bkp(Date) : backup the file
- Move(mv) sourcepath(file) targetpath(directory) : to move the file or directory
- du –sh : it shows the size of the file
- rm filename : it is used to remove the file
- -r file or directoryname : it is used to remove the multiple files and directories recursively
- -rf file or directory name : : it is used to remove the multiple files and directories force bully
- -rf file or directory name* : it is used to remove all the files and directories from the directory
- rmdir directoryname : it is used to remove the empty directories only
- head file name : number of pages from top of the file
- tail filename : number of pages from down of the file
- last : it shows the activity of the users
- ls –l |grep –l file or directoryname : it brings the specific file or directory for indentific either file or directory
- more filename : it shows the file content by line by line
- move(mv) oldfile or directoryname new file or directoryname : change the filename or directoryname
- cp –p filename targetpath : copy the same time stamp
- cpio source destination : this command copies only content of the file except inode and datablocks..By using this command avoid the unallocated space of the file it stores same size of the destination file
- > /path of the file(ex:>/var/log/message): null the file
Vi Editor
Command mode
- Vi filename : to create and edit the file
- yy : number of lines copy
- cc : number of lines cut
- p :past
- x : delete a character
- dw: delete the word
- dd : delete the entire row
- yw : copy the word
- r : we can replace the character
- R : overwrite
- cw :change the word
- o :create new line below the curssor
- O :create new line above the cursor
- Edit or insert mode
- I or a : before the cursor after the cursor for go to edit mode
- Esc : go to command mode
- Excute mode :
- :q! : without saving quit
- :wq! : quit with save
- Esc :go to command mode
Permissions for file or directory
- Chmod 755 directoryname : change the permissions(read write execute)
- Default file and directory permissions : file=664(umask 022, 666-022=644)directory=755(umask022,777-022=755)
- Chown user:group directoryname
- Chmod –R 777 /tmo/pune/room/raja :change the permissions progressively
- Permissions : read=4, write=2, execute=1
- Default permissions for file and directory : directory(755=drwxr-xr-x) file(644=-rw-r—r–)
User Management
- useradd username : create user
- user default configuration file : /etc/default/useradd
- groupadd groupname : create group
- useradd –u uid –g gid or gname –d /export/home/directoryname –s /bin/bash username : creating user and assaigning group
- lid –g groupname : open with group members
- groupmod –g newgid groupname : change the group id
- groupmod –g new groupname old groupname : change the group name
- cat/etc/passwd :it’s having user related information
- passwd username : create and change password for user
- cat/etc/shadow : it’s having users password related information
- useradd –u uid –g gid or gname –m –d /export/home/directoryname –s /bin/bash(shell) username: creating user with user’s home directory and ownership
- usermod –G primarygroup ,secondarygroup(12,13…)username: creating secondary groups of the particular user
- chmod –g target gid username: it is used for change the primary group
- id –a username :it is used for check the use information
- passwd –S username: to know the particular user password status
- –l username: it is used for lock the user
- –u username: to unlock the user
- -x no of days username : to set the password validity period
- -x -1 username :it is used for unexpaired user
- -d user name : it is used for delete the user password
- Userdel username:it is to delete the user
- -r username :it is to delete user with home directory
- groupdel groupname: delete empty group
- su username: change over from one user to another user
- putyy login: to log into another user
- telnet 0: change over from one user to another user
- useradd –D: it display the default user details
- cat /etc/default/useradd: user configuration file
- change –l username:to see particular user password, expire, warning etc status
- -E username: to set expire date
- -M username: to set max days
- -m username: to set minimum dats of expire
- -w username: to set warn days
- -d 0 username: user change passwd his self
DISK & FILE SYSTEM MANAGEMENT
- #echo ‘- – -‘ > /sys/class/scsi_host/host0/scan: it is used to intiate the disk partician to the kernal(update the luns form os level)
- fdisk -l: it is used to know the disk information
- fdisk /dev/sda(device name): enter in to the disk patrician
- mkfs.ext3(filesystemtype) /dev/sdb1(devise name): create file system
- mkfs -t filesystem type(ext3) device name(/dev/sdb1) : create file system
- mkdir /fs1 (directoryname): create directory for mount
- #mount -t ext3 /dev/sdb1 (devise to mount) /fs1(mountpoint): mount the file system
- vi /etc/fstab: to permanent the mounted file system
- cat /etc/mtab: to check the mounted file system information
- /proc/mount : to check the mounted file system information
- Unmount –a: unmount all file systems(it reads the /etc/mtab or /proc/mount files)
- Mount –a: mount all file systems (it reads the /etc/fstab file)
- df –h: mounted file system information(it reads the /etc/mtab)
- blkid : mounted and un-mounted information
swap management
- mkswap /dev/sdb1(device name): create swap devise
- swapon /dev/sdb1(device name) : create swap devis
- swapon -s : to know the swap device information
- top : to view the swap free space,used,total or check the system information
- free -m or #free -g or #cat /proc/meminfo or #top: to check the free space of swap
- dd if=/dev/zero of=/tmp/f1 bs=1M count=1: create sized file
- swapoff /dev/sdb1(device to mount) : stop the swap device
- fdisk /dev/sdb and then command(m for help) t: change for swap id(82)
- monitoring Commands: #swapon –s, #free -m, #top
PACKAGE & PATCH MANAGEMENT(package extension .rpm)
rpm -qa: check the all package
- -qi package name: particular package installed
- -ivh package name: package description after installation
- -e package name: install a particular package
- -uvh package name: remove the package
- -ivh package name –force: upgrade the package
- -qi command path(/bin/ls): forcely install package
- -ivh package name –force –nodeps: to know which package installed on particular command
PROCESS MANAGEMENT
- Jobs –l: forcely install the package without dependency(list of jobs)
- fg job id: fore ground process(Restart the background stoped jobs)
- ps –elf: it display the running process information
- kill -9 pid no or pkil -9 processname: kill the process
- kill –l: list of signals
- nohup cp source path target path: this command breaks parent and child relationship
service management
- service –status-all: it shows the total services information
- chkconfig –list: check modified services list
- service servicename(sshd) start or stop or restart: start or stop or restart the server
- /etc/init.id/ service name(sshd) start or stop or restart: start or stop or restart the server
- chconfig service name (sshd) –level 0123456 on or off: on or off the server at certain level
- /etc/init.d/service status: to know the status of service
- Service service name(sshd) status: to know the status of service
Job management
- Date: it display the week date month year and time
- Tty: display the terminal name
- Which command name: it shows that command where it is located
- atrm job id: remove the atjobs
- at time: by using this command one time schedule the function of job
- atq or at –l: list of one time schedule time
- crontab –e: by using this command create repeated schedule the function of job
- crontab –l: list of repeated schedule the function of job
- /var/cron/logs: we can observe all executed cronjobs here
- /var/log/cron(in linux): we can observe all executed cronjobs here
- cat /etc/crontab: it is configuration file of cron tab jobs
LOGICAL VOLUME MANAGER (LVM)
- pvcreate diskname(/dev/sdb): create physical volume
- pvdisplay #pvscan: it will display the physical volumes
- vgcreate name of vg diskname(/dev/sdb): create volume group
- vgextend vg /dev/sdc(diskname): extend the volume group
- vgdisplay: it will display the volume group information
- vgs: it will display the volume groups
- lvcreate -L +200M (size) vg -n lv: create logical volume
- lvdisplay: it will display the logical volumes
- lvdisplay /dev/vgname/lvname -m:it will display either it is stripted or lenear volume(cocandination)
- lvextend -L +100M(size) /dev/vg/lv: extended the logical volume size
- resize2fs /dev/vg/lv: update the file system size
- lvcreate -L +200M(size) -I 2 (no of striped bit 1,2,3,4,6…) vg -n lv striping: create striped logical volume
- remove lvname: remove the logical volume
- vgname: remove volume group
- pvname: remove physical volume
mirror lvcreate
- lvcreate -L +2G -m1 –corelog -n lvname vgname for mirror lenearvolume: create logical volume in mirror lenear volume
- lvcreate -L +2G -I2 -m1 –corelog -n lvname vgname for mirror striping: : create logical volume in mirror striped volume
FILE SYSTEM ARCHITECTURE
- ls -la: list of hidden files
- ls -a <folder name>: list of hidden files
- touch .filename: create the hidden file
- ls -li: list of inodes
- stat filename: it shows the ,size ,inodes , ioblocks ,links ,access ,modify ,change of the file
LINKS
- ln (within the fs) backup the file: to create hard link
- -s (across the fs) create shortcut: to create soft link
NETWORKING
- Ipconfig /all note: it’s working in windows
- ping 127.0.0.1: to get ipaddress and related information
- ping ipaddress(192.168.1.19): to check ip is working or not
- ifconfig -a: to check the nic cards
- ifconfig eth0 or 1 2…: to check the specific nic cards
- ifup eth: up the nic cards
- ifdown eth: down the nice cards
- ifconfig eth 192.168.1.160(ip) netmask 255.255.255.0 up: configure the ip
- vi /etc/sysconfig/network-scripts/ifcfg –eth: permanent the configured ip
- cat /etc/sysconfig/network-scripts/ifcfg – eth: open the configured ip info
- /etc/redhat-release: to see the current linux version
- /etc/issues: to see the current linux version
- /etc/services: it display the all port numbers
- /etc/hosts: to see the ip address with its assigned hostname
- cat /etc/services: it display the all port numbers
- service service name start ,stop or restart (syntax: service network start,stop,restart): restart the server
- vi /etc/hosts: to assign hostname to ip address
- uname –a: to assign the current linux version with hardware details too
- hostname: to see the current using host name
- hostname new hostname: to assign new hostname
- -i : to see the ip address with which we logged in
NETWORKING CONFIGARATION FILES
- /etc/sysconfig/network-scripts/ifcfg-eth0
- /etc/sysconfig/network
- /etc/hosts
NFS (Network File System)(it is used for centralised file system)
- Server
- mkfs.ext3 /dev/sdb1
- mkdir /nfs
- mount -t ext3 /dev/sdb1 /nfs :to put fs details in /nfs
- vi /etc/exports /nfs *(rw,async): it reads andshare the export fs
- exportfs : it re-reads and share the export fs( it sharing more than one files)
- exportfs -arv: list of export files
- showmount –e:it showing yo had shared from how many hosts
- showmount -e server hostname: to perminant
- vi /etc/fstab: nfs configuration file
- /etc/sysconfignfs: nfs configuration file
- /etc/exports
- nfs demons
- nfsd (request&response for nfs clints):
- mountd(give the authentication for client request)
- statd(it works with lockd it provides the crass and recovery functions for the lock manager)
- lockd(it sends the locking request from client to nfs server)
- CLIENT
- mkdir /arr : to create mount point
- mount -t nfs reddy-sys3:/nfs /arr : mount shared fs
- vi /etc/fstab (/nfs /arr nfs defaults 0 0 ): to perminant
- to create centralised file system
- we have to create ,mount point ,password,user,group, with the same gid,uid,password, and mount point of server
AUTO FS (it is used for centralised home directory)
- CLIENT direct map:
- service autofs restart : it will restart the service
- vi /etc/auto.master (/- /etc/auto.direct –timeout=60)
- vi /etc/auto.direct (/mountpoint -rw,intr raja-sys1:/mountpoint)
- vi /etc/auto.direc (/mountpoint -rw,intr raja-sys1:/mountpoint)
- CLIENT indirect map
- service autofs restart
- vi /etc/auto.master (/mountpoint /etc/auto.indirect –timeout=60)
- vi /etc/auto.indirect(*-rw,intr raja-sys1:/mountpoint)
- automount -v
- AUTO FS CONFIGARATION FILES
- /etc/auto. master
- /etc/auto. direct
- /etc/auto.indirect
- autofs demon
- automountd
NIS SERVER (it is used for centralized login)
- service ypbind start: configure the nis server
- /usr/lib64/yp/ypinit -m: to know the server bind with clint or not
- Ypwhich: it display the all remote users
- ypcat passwd
- NIS CLIENT
- service ip tables stop
- setup (for authentication configaration ,here given the domain name & server name): to know the client bind with server or not
- Ypwhich: it display the all remote users
- ypcat passwd
- NIS CONFIGARATION FILES
- /etc/nsswitch.conf
- /etc/yp.conf
- NIS DEMONS
- ypserv (it have original source asky file by using those sky files create maps)
- yppasswd (Lets users change their passwords on the NIS server from NIS clients)
- ypbind (it will always bind with nis server when the nis server is demonism the ypbind automatically bind with another nis server)
- ypxfrd (Used to speed up the transfer of very large NIS maps)
SCP (SECURE COPY)
- DEF: secure copy is to copy files from one host to another host or simply across the systems of same platform
- #scp source path of sender hostname of receiver or ipaddr:/target path of receiving system: to copy files when we are in source path
- #scp hostname or ipaddr:/source path target path of receiving system : to copy files when we are in target path\
CONVERSION OF FILES TO ZIP AND VICEVERS
- ****** to convert any file into zip or to compress first the file should be converted into .tar file to copy files when we are in target path
- tar -cvf raja.tar (name of file) f1 f2 f3 f4 f5 f6 (files to be zipped ): to create a .tar file (raja.tar)
- tar -tvf raja.tar (name of .tar file ): to view the .tar file
- tar -uvf raja.tar f1 (file name to upend ): to upend a file or files
- tar -xvf raja.tar (tar filename): to extract a tar file
- gzip raja.tar: : to create gz file
- gunzip raja.tar.zp: to extract the gz file
- bzip raja.tar: to create the bz file
- bunzip raja.tar.bz: to extract the bz file
- compress raja.tar :to create the z file
- uncompress raja.tar.z: to extract the z file
SUDO
- vi /etc/sudoers (%raja ALL=(ALL) ALL) ex: sudo mkdir arr: all permissions are applied
- /etc/sudoers (%india ALL=(ALL) ALL) : group permission (sachin ,sehwag,dhoni,kohli,raina,rohith)
- /etc/sudoers (%india ALL=(ALL) NOPASSWD=ALL): now it’s never ask password befpre excuting new command
- /etc/sudoers (%raja ALL=(ALL) mkdir,cat):he can excute those two commands only
VARTUAL IP’S
- ifconfig eth0:1 192.168.1.160/24 up (note: class c netmask=/24): TO assign more than one ip to a single nic card is calle vartual ip
- ifconfig eth0:2 192.168.1.161/24 up: to assign the vartual ip to a eth0
- cd /etc/sysconfig/netwrk-cripts cp ifcfg-eth0 eth0:1 vi ifcfg-eth0:1: create eth0:1 file and copy the content of eth0
BONDING
- cd /etc/sysconfig/netwrk-scripts: create master file
- vi /etc/sysconfig/netwrk-scripts/ifcfg-bond1 (device=bond1,master=yes,onboot=yes,netmask,ipaddr,gateway,type): create slave1
- vi /etc/sysconfig/netwrk-scripts/ifcfg-eth1 (device=eth1,slave=yes,master=bond1,onboot=yes,hwaddr): create slav2
- vi /etc/sysconfig/netwrk-scripts/ifcfg-eth2 (device=eth2,slave=yes, master=bond1,onboot=yes,hwaddr): it’s configuration file for bonding
- vi /etc/modprobe.conf (alias bond1 bonding nextline options bond1 mode=balance-alb minimum=100): it’s update to the kernel
- modprobe bonding
- service network reload: it display how many nics having bond1
- cat /proc/net/bonding/bond1
DEFAULT GATEWAY
- route add -net ipseris netmask gw : add gate way to the specific ipseris
- route dell gw : delete gate way
- route add default gw : add default gate way
- route dell default gw : add default gate way
- vi /etc/sysconfig/network-scripts/route-eth0 (ip series via gateway Ex 172.16.0.0 via 172.16.1.120): by using ssh authentication we can login in to another host without password in secure way.
SSH AUTHENTICATION(
- ssh-keygen -t rsa: it will create .ssh,public and private keys
- touch authorized_keys: the file create the our target host of from user home directory
ssh username@target host: login in to host after complete of the above process