LINUX BASICS -----------COMMANDS FOR CUI AND GUI ALT+CTRL+[F1 TO F6] --> default virtual terminal for CUI we can create virtual terminal upto 65 ALT+CTRL+F7--> It will be open on GUI mode local host login: root (or user name) password : 123456 (given passwd) ==-> CHANGING ROOT PASSWD AFTER LOGIN [root@localhost ~]# passwd root Changing password for user root. New UNIX password: BAD PASSWORD: it is too simplistic/systematic Retype new UNIX password: passwd: all authentication tokens updated successfully. ROOT INFORMATIONS _________________ [root@localhost ~]# id root uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel) [root@localhost ~]# who am i root pts/1 Mar 21 18:06 (:0.0) [root@localhost ~]# w 18:14:42 up 20 min, 2 users, load average: 0.29, 0.39, 0.43 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT root :0 17:56 ?xdm? 3:03 1.73s /usr/bin/gnome-session root pts/1 :0.0 18:06 0.00s 0.35s 0.03s w [root@localhost ~]# who root :0 Mar 21 17:56 root pts/1 Mar 21 18:06 (:0.0) [root@localhost ~]# users root root [root@localhost ~]# [username@localhost ~]$ (this $ willdisplay for user) ---------------------------------------------------------------------------LISTS ----1) For displaying the list of the directories ls - list directory contents [root@localhost ~]# ls anaconda-ks.cfg ibrahim install.log.syslog sir Desktop install.log shajeeh [root@localhost ~]# ls /sys/class firmware input misc netlink printer sound usb vc graphics mem net pci_bus raw tty usb_host [root@localhost ~]# cd / [root@localhost /]# ls
backup usr bin var
boot
etc
initrd
lost+found
misc
opt
root
selinux
sys
dev
home
lib
media
mnt
proc
sbin
srv
tmp
[root@localhost ~]# dir anaconda-ks.cfg Desktop shajeeh sir
ibrahim
install.log
install.log.syslog
_______________________________________________________________________ ______ 2) Changing the directory Read and execute commands from filename in the current shell [root@localhost /]# ls backup boot etc initrd lost+found misc opt root selinux sys usrbin dev home lib media mnt proc sbin srv tmp var[root@localhost /]# cd media [root@localhost media]# ls cdrecorder cdrom floppy [root@localhost media]# cd cdrom [root@localhost cdrom]# ls _______________________________________________________________________ ______ 3) present working directory pwd - print name of current/working directory [root@localhost ~]# cd / [root@localhost /]# pwd / [root@localhost /]# cd [root@localhost ~]# cd /home [root@localhost home]# pwd /home _______________________________________________________________________ ______ 4)Absolute path absolut path is /root directory [root@localhost ~]# cd / [root@localhost /]# ls backup dev initrd media notes basic root srv usr bin etc lib misc opt sbin sys var boot home lost+found mnt proc selinux tmp [root@localhost /]# cd mnt [root@localhost mnt]# ls [root@localhost mnt]# cd [root@localhost ~]# pwd /root [root@localhost ~]# --> absolute path directory _______________________________________________________________________ ______ 5)changing directory to One level up [root@localhost ~]# cd / [root@localhost /]# ls
backup dev initrd media notes basic root srv usr bin etc lib misc opt sbin sys var boot home lost+found mnt proc selinux tmp [root@localhost /]# cd /home [root@localhost home]# ls amba shoaib [root@localhost home]# cd shoaib [root@localhost shoaib]# cd .. [root@localhost home]# cd .. [root@localhost /]# pwd / [root@localhost /]# _______________________________________________________________________ ______ 6)Previous working directory (cd - ) [root@localhost /]# ls backup dev initrd media notes basic root srv usr bin etc lib misc opt sbin sys var boot home lost+found mnt proc selinux tmp [root@localhost /]# cd media/ [root@localhost media]# ls cdrecorder cdrom floppy [root@localhost media]# cd cdrom [root@localhost cdrom]# cd /media [root@localhost media]# pwd /media [root@localhost media]# _______________________________________________________________________ ______ 7) Listing directory #ls --> list #ls -a --> for hidden files #ls -l --> detailof logon list #ls -r --> list #ls -d --> touch files with dot #ls -i --> it desplay the inode no.of files in present dir. _______________________________________________________________________ ______ 8) System directories boot etc bin dev sys usr
initrd home
lost+found lib
misc proc media mnt
sbin opt
srv root
tmp var selinux
There will be default 22 system directories. _______________________________________________________________________ ______ 9) checking Free space for directories as well as Hard drive [root@localhost ~]# df --> show info files system use space and mount dir. Filesystem 1K-blocks Used Available Use% Mounted on /dev/hdc3 4198268 3681200 303808 93% / /dev/hdc2 101105 8462 87422 9% /boot
none /dev/sda1
95644 1013792
0 145412
95644 868380
0% /dev/shm 15% /media/USB_DISK
[root@localhost ~]# df -h --> same as "df" but showing file in G.B Filesystem Size Used Avail Use% Mounted on /dev/hdc3 4.1G 3.6G 297M 93% / /dev/hdc2 99M 8.3M 86M 9% /boot none 94M 0 94M 0% /dev/shm /dev/sda1 991M 143M 849M 15% /media/USB_DISK [root@localhost ~]# df -H --> Filesystem Size /dev/hdc3 4.3G /dev/hdc2 104M none 98M /dev/sda1 1.1G
exact size******** Used Avail Use% Mounted on 3.8G 312M 93% / 8.7M 90M 9% /boot 0 98M 0% /dev/shm 149M 890M 15% /media/USB_DISK
[root@localhost ~]# df -T =-> IT SHOWS DISK SPACE AND FILE TYPES Filesystem Type 1K-blocks Used Available Use% Mounted on /dev/hdc3 ext3 4198268 3683192 301816 93% / /dev/hdc2 ext3 101105 8462 87422 9% /boot none tmpfs 95644 0 95644 0% /dev/shm [root@localhost home]# du --> display info of files & total size 16 ./amba/.metacity/sessions 24 ./amba/.metacity 16 ./amba/.gstreamer-0.8 16 ./amba/.gnome/gnome-vfs 8 ./amba/.gnome/mime-info 32 ./amba/.gnome 52 ./amba/.gconfd 16 ./amba/.nautilus/metafiles 24 ./amba/.nautilus 8 ./amba/Desktop 48 ./amba/.config/menus 56 ./amba/.config 16 ./amba/.gconf/desktop/gnome/file_views 16 ./amba/.gconf/desktop/gnome/peripherals/keyboard/xkb.sysbackup 16 ./amba/.gconf/desktop/gnome/peripherals/keyboard/xkb 44 ./amba/.gconf/desktop/gnome/peripherals/keyboard 56 ./amba/.gconf/desktop/gnome/peripherals 16 ./amba/.gconf/desktop/gnome/applications/window_manager 28 ./amba/.gconf/desktop/gnome/applications 112 ./amba/.gconf/desktop/gnome 124 ./amba/.gconf/desktop 16 ./amba/.gconf/apps/panel/general 16 ./amba/.gconf/apps/panel/applets/clock/prefs 28 ./amba/.gconf/apps/panel/applets/clock 16 ./amba/.gconf/apps/panel/applets/mixer/prefs 28 ./amba/.gconf/apps/panel/applets/mixer 16 ./amba/.gconf/apps/panel/applets/window_list/prefs 28 ./amba/.gconf/apps/panel/applets/window_list 16 ./amba/.gconf/apps/panel/applets/workspace_switcher/prefs 28 ./amba/.gconf/apps/panel/applets/workspace_switcher 124 ./amba/.gconf/apps/panel/applets 16 ./amba/.gconf/apps/panel/toplevels/bottom_panel
28 16 16 44 224 16 252 384 8 16 16 40 28 36 44 8 8 116 8 8 848 48 904
./amba/.gconf/apps/panel/toplevels ./amba/.gconf/apps/panel/objects/web_launcher ./amba/.gconf/apps/panel/objects/email_launcher ./amba/.gconf/apps/panel/objects ./amba/.gconf/apps/panel ./amba/.gconf/apps/nautilus ./amba/.gconf/apps ./amba/.gconf ./amba/.gnome2/keyrings ./amba/.gnome2/share/fonts ./amba/.gnome2/share/cursor-fonts ./amba/.gnome2/share ./amba/.gnome2/panel2.d/default/launchers ./amba/.gnome2/panel2.d/default ./amba/.gnome2/panel2.d ./amba/.gnome2/accels ./amba/.gnome2/nautilus-scripts ./amba/.gnome2 ./amba/.eggcups ./amba/.gnome2_private ./amba ./shoaib .
[root@localhost ~]# du -sh --> display total size of directories 1.7M . [root@localhost ~]# cd /home --> example :-2 [root@localhost home]# du -sh 904K . _______________________________________________________________________ ______ 10) Creating directories. [root@localhost /root [root@localhost [root@localhost anaconda-ks.cfg mango shajeeh
~]# pwd ~]# mkdir mango ~]# ls Desktop ibrahim sir
install.log
install.log.syslog
[root@localhost ~]# mkdir /apple [root@localhost ~]# cd / [root@localhost /]# ls apple bin dev home lib media mnt opt root selinux sys usr backup boot etc initrd lost+found misc notes basic proc sbin srv tmp var [root@localhost /]# pwd / ==-> CREATING MULTEPEL DIR.S mkdirhier (1x) - makes a directory hierarchy [root@localhost ~]# mkdirhier jaweed jabbar [root@localhost ~]# ls anaconda-ks.cfg comp1 Desktop door install.log.syslog jawed a.out comp2 doc.txt install.log jabbar jaweed
_______________________________________________________________________ ______ 11) Making touch files in a directory [root@localhost ~]# cd mango/ [root@localhost mango]# touch file1 file2 [root@localhost mango]# ls file1 file2 [root@localhost mango]# pwd /root/mango [root@localhost mango]# cd [root@localhost ~]# touch /apple/data [root@localhost ~]# cd /apple/ [root@localhost apple]# ls data [root@localhost apple]# pwd /apple _______________________________________________________________________ ______ 12) Editing Touch files [root@localhost ~]# cd mango/ [root@localhost mango]# ls file1 file2 [root@localhost mango]# cat > file1 jabbar bhai assalam alaikum.Kaisse hoaa aap enter --> 1)for exit ctrl+d --> 2) for exit [root@localhost mango]# cat file1 jabbar bhai assalam alaikum.Kaisse hoaa aap [root@localhost mango]# ==-> "LESS" COMMAND IS USE FOR VIEW THE FILE PAGE WISE [root@localhost ~]# less install.log _______________________________________________________________________ ______ b) Adding more lines in touch files [root@localhost mango]# ls file1 file2 [root@localhost mango]# cat file1 jabbar bhai assalam alaikum.Kaisse hoaa aap [root@localhost mango]# cat >> file1 Main yah per theek hooa shoaib enter ctrl+d [root@localhost mango]# cat file1 jabbar bhai assalam alaikum.Kaisse hoaa aap main yah per theek hooa shoaib _______________________________________________________________________ ______ c) editing the whole touch file by VI editor. [root@localhost ~]# cd mango [root@localhost mango]# ls file1 file2 [root@localhost mango]# vi file1 jabbar bhai assalam alaikum.Kaisse hoaa aap
Main yah per theek hooa shoaib... aaj mujhe phone karo... esc shift+: wq (for save and exit) [root@localhost mango]# cat file1 jabbar bhai assalam alaikum.Kaisse hoaa aap Main yah per theek hooa shoaib... aaj mujhe phone karo... _______________________________________________________________________ ______ D) for seeing how much line,how much worrds & how much characters in file [root@localhost ~]# mkdir data [root@localhost ~]# cd data [root@localhost data]# [root@localhost data]# touch file [root@localhost data]# ls file [root@localhost data]# cat > file [root@localhost data]# cat file LT+CTRL+[F1 TO F6] --> default virtual terminal for CUI we can create virtual terminal upto 65 ALT+CTRL+F7--> It will be open on GUI mode local host login: root (or user name) password : 123456 (given passwd) [root@localhost data]# wc file 8 36 217 file [root@localhost data]# wc -l file 8 file [root@localhost data]# wc -w file 36 file [root@localhost data]# wc -L file 55 file [root@localhost data]# wc -c file 217 file wc= word count l= line w= words L= c= characters ==-> CHECKING SPELLING IN A TEXT FILE [root@localhost ~]# cat >> text2 jawed jabbar how r you [root@localhost ~]# aspell check text2 i) Ignore r) Replace a) Add b) Abort [root@localhost ~]# aspell check text3.txt ==-> USE SPELLING DICTIONARY
I) R) l) x)
Ignore all Replace all Add Lower Exit
[root@localhost ~]# look symbolic symbolic symbolical symbolically symbolicalness symbolicly symbolics _______________________________________________________________________ ______ E) RENAMING FILE NAMES [root@localhost ~]# cd data [root@localhost data]# ls file [root@localhost data]# mv file doc [root@localhost data]# ls doc _______________________________________________________________________ _____ F) MOVING FILE [root@localhost data]# ls doc [root@localhost data]# mv doc /root/doc [root@localhost data]# ls [root@localhost data]# cd [root@localhost ~]# ls anaconda-ks.cfg Desktop ibrahim install.log.syslog mango sir data doc install.log ls -a shajeeh _______________________________________________________________________ _____ G) MOVE FILE AND CHANGE NAME ALSO [root@localhost ~]# cd data [root@localhost data]# touch text1 text2 [root@localhost data]# ls text1 text2 [root@localhost data]# mv text1 /root/file1 [root@localhost data]# ls text2 [root@localhost data]# cd [root@localhost ~]# ls anaconda-ks.cfg Desktop file1 install.log ls -a shajeeh data doc ibrahim install.log.syslog mango sir _______________________________________________________________________ ____ H) MOVING MULTIPLES FILES FROM ONE DIR TO ANOTHER DIR [root@localhost ~]# cd data [root@localhost data]# touch text1 text3 text4 text5 [root@localhost data]# ls text1 text2 text3 text4 text5 [root@localhost data]# mv text1 text2 text3 text4 text5 /root [root@localhost data]# ls [root@localhost data]# cd [root@localhost ~]# ls anaconda-ks.cfg Desktop file1 install.log ls -a shajeeh text1 text3 text5
data doc ibrahim install.log.syslog mango sir text2 text4 _______________________________________________________________________ __ I) REMOVING (del) FILE [root@localhost ~]# ls anaconda-ks.cfg Desktop file1 install.log text1 text3 text5 data doc ibrahim install.log.syslog text2 text4 [root@localhost ~]# rm text1 rm: remove regular empty file `text1'? y [root@localhost ~]# ls 'anaconda-ks.cfg Desktop file1 install.log text2 text4 data doc ibrahim install.log.syslog text3 text5
ls -a
shajeeh
mango
sir
ls -a mango
shajeeh sir
J)REMOVING (del) MULTIPLE FILES [root@localhost ~]# ls anaconda-ks.cfg Desktop file1 install.log ls -a shajeeh data doc ibrahim install.log.syslog mango sir [root@localhost ~]# cd data [root@localhost data]# ls text2 text3 text4 text5 [root@localhost data]# rm * rm: remove regular empty file `text2'? y rm: remove regular empty file `text3'? y rm: remove regular empty file `text4'? y rm: remove regular empty file `text5'? y [root@localhost data]# ls [root@localhost data]# _______________________________________________________________________ ______ 13=->REMOVING COMMANDS 1=> 2=> 3=> 4=> 5=> 6=>
rmdir =-> for deleting only rm file name rm -r =-> for removing dir rm -ri =-> for removing dir rm -rf =-> for removing dir rm * =-> for removing all
empty dir and its cantains(ask for every data) and its cantains(ask for every data) and files without asking dir's and files in present filesystem
A=-> REMOVING EMPTY DIR [root@localhost [root@localhost anaconda-ks.cfg sir data [root@localhost [root@localhost anaconda-ks.cfg data
~]# mkdir jawed ~]# ls Desktop file1 doc ~]# rmdir ~]# ls Desktop doc
install.log
jawed
mango
ibrahim jawed
install.log.syslog
ls -a
shajeeh
file1 ibrahim
install.log install.log.syslog
ls -a mango
shajeeh sir
_______________________________________________________________________ ____ B)=-> REMOVING MULTIPLE EMPTY DIR Ex.=->[root@localhost ~]# rmdir * _______________________________________________________________________ ____ C)=-> REMOVING DIR AND ITS CANTAINS [root@localhost [root@localhost [root@localhost [root@localhost [root@localhost rain
~]# mkdir shajeeh ~]# mkdir shajeeh ~]# cd shajeeh shajeeh]# touch rain shajeeh]# ls
[root@localhost ~]# mkdir jabbar [root@localhost ~]# ls anaconda-ks.cfg Desktop file1 install.log sir data doc ibrahim install.log.syslog [root@localhost ~]# rm -r shajeeh rm: descend into directory `shajeeh'? y rm: remove regular empty file `shajeeh/rain'? y rm: remove directory `shajeeh'? y [root@localhost ~]# rm -r jabbar rm: remove directory `jabbar'? y [root@localhost ~]# ls anaconda-ks.cfg Desktop file1 install.log data doc ibrahim install.log.syslog
jabbar
mango
ls -a
shajeeh
ls -a mango
sir
METHOD -2 [root@localhost ~]# mkdir wahid [root@localhost ~]# touch /root/wahid/parle-G [root@localhost ~]# ls /root/wahid parle-G [root@localhost ~]# rm -ri wahid rm: descend into directory `wahid'? y rm: remove regular empty file `wahid/parle-G'? y rm: remove directory `wahid'? y [root@localhost ~]# ls anaconda-ks.cfg Desktop file1 install.log ls -a sir data doc ibrahim install.log.syslog mango _______________________________________________________________________ ______ D)REMOVING DIR AND FILES WITHOUT ASKING [root@localhost ~]# mkdir mango [root@localhost ~]# cd mango [root@localhost mango]# ls file1 file2 [root@localhost mango]# cd [root@localhost ~]# rm -rf mango [root@localhost ~]# ls anaconda-ks.cfg data Desktop doc install.log.syslog ls -a sir
file1
ibrahim
install.log
_______________________________________________________________________ ______ 14=->COPYING FILES AND DIR [root@localhost ~]# cd data [root@localhost data]# ls [root@localhost data]# touch file file1 file2 file3 file4 [root@localhost data]# ls file file1 file2 file3 file4 [root@localhost data]# cd [root@localhost ~]# mkdir idris [root@localhost ~]# ls anaconda-ks.cfg data doc ibrahim install.log ls -a a.out Desktop file1 idris install.log.syslog sir [root@localhost ~]# cd data [root@localhost data]# ls file file1 file2 file3 file4 [root@localhost data]# cp file /root/idris [root@localhost data]# ls /root/idris file _______________________________________________________________________ _____ A) COPYING MULTIPLE FILES [root@localhost data]# cp * /root/idris cp: overwrite `/root/idris/file'? y [root@localhost data]# ls /root/idris file file1 file2 file3 file4 _______________________________________________________________________ _____ B) COPYING DIR AND ITS CONTAINS [root@localhost ~]# ls anaconda-ks.cfg data doc ibrahim install.log ls -a a.out Desktop file1 idris install.log.syslog sir [root@localhost ~]# cp -r idris / [root@localhost ~]# cd / [root@localhost /]# ls 123 bin etc initrd lost+found mnt proc selinux tmp xyz apple boot home lib media notes basic root srv usr backup dev idris linuxnotes misc opt sbin sys var _______________________________________________________________________ _____ C)=->COPYING MULTIPLE DIR AND FILES [root@localhost /]# mkdir atique [root@localhost /]# ls 123 bin etc initrd lost+found mnt tmp xyz apple boot home lib media notes basic atique backup dev idris linuxnotes misc opt var [root@localhost /]# cd
proc root
selinux
srv sbin sys
usr
[root@localhost ~]# cp -r * /atique [root@localhost ~]# ls /atique anaconda-ks.cfg data doc ibrahim install.log ls -a a.out Desktop file1 idris install.log.syslog sir _______________________________________________________________________ ______ D)=-> COPYING DIR FROM ONE TO OTHER DIR [root@localhost ~]# mkdir jawed [root@localhost ~]# ls anaconda-ks.cfg a.out Desktop install.log install.log.syslog [root@localhost ~]# cd jawed [root@localhost jawed]# touch text1 text2 [root@localhost jawed]# cd [root@localhost ~]# cp -r jawed jabbar [root@localhost ~]# ls anaconda-ks.cfg a.out Desktop install.log install.log.syslog jabbar jawed [root@localhost ~]# ls jabbar text1 text2 ==-> cp -p MEANS COPY WITH PRESERVE TIME DATE
jawed
[root@localhost ~]# cp -p install.log /mnt [root@localhost ~]# ls -l /mnt total 52 -rw-r--r-- 1 root root 47055 Mar 16 15:01 install.log ==-> cp -r MEANS COPY WITH PRESENTE TIME DATE [root@localhost ~]# cp -r install.log /home [root@localhost ~]# ls -l /home -rw-r--r-- 1 root root 47055 Mar 22 16:01 install.log _______________________________________________________________________ ______ 15) VIEWING TEXT FILES [root@localhost ~]# cat anaconda-ks.cfg # Kickstart file automatically generated by anaconda. install cdrom lang en_US.UTF-8 langsupport --default=en_US.UTF-8 en_US.UTF-8 keyboard us xconfig --card "SiS 6326" --videoram 4096 --hsync 30-61 --vsync 50-120 --resolution 800x600 --depth 16 --startxonboot --defaultdesktop gnome network --device eth0 --bootproto dhcp rootpw --iscrypted $1$pkrYuv2a$rq06n4VwoKS4B1ReFRlbE0 firewall --enabled selinux --enforcing A)=-> IT SHOWS TEN LINES OF TEXT [root@localhost ~]# head anaconda-ks.cfg # Kickstart file automatically generated by anaconda. install cdrom
lang en_US.UTF-8 langsupport --default=en_US.UTF-8 en_US.UTF-8 keyboard us xconfig --card "SiS 6326" --videoram 4096 --hsync 30-61 --vsync 50-120 --resolution 800x600 --depth 16 --startxonboot --defaultdesktop gnome network --device eth0 --bootproto dhcp rootpw --iscrypted $1$pkrYuv2a$rq06n4VwoKS4B1ReFRlbE0 [root@localhost ~]# head -n4 anaconda-ks.cfg # Kickstart file automatically generated by anaconda. install cdrom B)=-> IT SHOWS LAST TEN LINES OF TEXT [root@localhost ~]# tail anaconda-ks.cfg @ base-x @ web-server @ printing @ server-cfg @ graphical-internet kernel grub e2fsprogs %post [root@localhost ~]# tail -n5 anaconda-ks.cfg kernel grub e2fsprogs %post C)=-> CREATING .TXT FILES [root@localhost ~]# touch file.txt [root@localhost ~]# ls anaconda-ks.cfg a.out Desktop file.txt install.log install.log.syslog jabbar jawed D)=-> RENAMING .TXT FILES [root@localhost ~]# ls anaconda-ks.cfg a.out Desktop file.txt install.log install.log.syslog jabbar jawed [root@localhost ~]# mv file.txt doc.txt [root@localhost ~]# ls anaconda-ks.cfg a.out Desktop doc.txt install.log install.log.syslog jabbar jawed _______________________________________________________________________ ______ 16=-> MOUNTING CDROM/CDRECORDER/FLOPPY/USB_DISK a)=->[root@localhost b)=->[root@localhost c)=->[root@localhost d)=->[root@localhost
~]# ~]# ~]# ~]#
mount mount mount mount
/media/cdrom /media/cdrecorder /media/floppy /media/USB_DISK
[root@localhost ~]# umount /media/(USB_DISK/cdrom/cdrecorder/floppy) _______________________________________________________________________ ______ 17=-> HOW TO USE CDROM [root@localhost ~]# eject [root@localhost ~]# mount /media/cdrom mount: block device /dev/hda is write-protected, mounting read-only [root@localhost ~]# ls /media/cdrom/RedHat/RPMS [root@localhost ~]# umount /media/cdrom [root@localhost ~]# eject _______________________________________________________________________ ______ 18=-> FINDING DIR.S FILES IN FILESYSTEM [root@localhost ~]# mkdir /root/door [root@localhost ~]# touch /root/door/touchfile [root@localhost ~]# find / -name door /root/door [root@localhost ~]# find / -name touchfile /root/door/touchfile ______________________________________________________________________ 19=-> COMPRESS FILES AND DIR'S OF SYSTEM FILES [root@localhost ~]# gzip -v /root/door/touchfile /root/door/touchfile: 0.0% -- replaced with /root/door/touchfile.gz [root@localhost ~]# ls /root/door/touchfile.gz /root/door/touchfile.gz [root@localhost ~]# cd /root/door [root@localhost door]# ls touchfile.gz [root@localhost ~]# ls anaconda-ks.cfg a.out Desktop doc.txt door install.log install.log.syslog jabbar jawed [root@localhost ~]# gunzip /root/door/touchfile.gz [root@localhost ~]# ls /root/door/touchfile /root/door/touchfile [root@localhost ~]# bzip2 -v install.log install.log: 4.511:1, 1.774 bits/byte, 77.83% saved, 47055 in, 10432 out. [root@localhost ~]# ls anaconda-ks.cfg Desktop door install.log.syslog jawed a.out doc.txt install.log.bz2 jabbar [root@localhost ~]# bunzip2 install.log.bz2 [root@localhost ~]# ls anaconda-ks.cfg a.out Desktop doc.txt door install.log install.log.syslog jabbar jawed _______________________________________________________________________ _____ 20=-> PERMISSIONS ONLY SUPER USER(root)CAN ASSIGN PERMISSION ADMINISTARTOR | _________________|__________________ | | \|/ \|/
GROUP1 | | ________|___________ | | \|/ \|/ USER1 USER2
GROUP2 | | _________|__________ | \|/ USER3
=-> OCTAL NOTATION a)=-> EXECUTE--------------(x or 1) b)=-> WRITE----------------(w or 2) c)=-> WRITE,EXECUTE--------(wx or 3) d)=-> READ-----------------(r or 4) e)=-> READ,EXECUTE---------(rx or 5) f)=-> READ,WRITE-----------(rw or 6) g)=-> READ,WRITE,EXECUTE---(rwx or 7) h)=-> STICKY BIT-----------(0)-ZERO =->OWNER GROUP USER | | | o g u :-->Ex.1 [root@localhost ~]# ls -l jawed total 16 -rw-r--r-- 1 root root 1377 Mar 20 21:18 text1 -rw-r--r-- 1 root root 301 Mar 20 21:17 text2 | | | o g u [root@localhost ~]# chmod 777 /root/jawed/text1 [root@localhost ~]# ls -l jawed total 16 -rwxrwxrwx 1 root root 1377 Mar 20 21:18 text1 -rw-r--r-- 1 root root 301 Mar 20 21:17 text2 [root@localhost ~]# chmod g+wr /root/jawed/text2 [root@localhost ~]# ls -l jawed total 16 -rwxrwxrwx 1 root root 1377 Mar 20 21:18 text1 -rw-rw-r-- 1 root root 301 Mar 20 21:17 text2 =->SAME AS DIR. [root@localhost ~]# mkdir /root/jawed/yahoo [root@localhost ~]# ls -l jawed total 24 -rwxrwxrwx 1 root root 1377 Mar 20 21:18 text1 -rw-rw-r-- 1 root root 301 Mar 20 21:17 text2 drwxr-xr-x 2 root root 4096 Mar 21 16:45 yahoo [root@localhost ~]# chmod +x text2 [root@localhost ~]# ls ahmed comp1 gun jawed anaconda-ks.cfg comp2 install.log jaweed a.out Desktop install.log.syslog text1 [root@localhost ~]# chmod ugo-x text2 [root@localhost ~]# ls ahmed comp1 gun jawed anaconda-ks.cfg comp2 install.log jaweed a.out Desktop install.log.syslog text1 : ==->METHOD TWO [root@localhost ~]# ls
| \|/ USER4
text1.bak text2 text2.bak
topi urdu
text1.bak text2 text2.bak
topi urdu
ahmed comp1 anaconda-ks.cfg comp2 a.out Desktop [root@localhost ~]# chmod [root@localhost ~]# ls ahmed comp1 anaconda-ks.cfg comp2 a.out Desktop
gun install.log install.log.syslog ugo+x text1.bak
jawed jaweed text1
text1.bak text2 text2.bak
topi urdu
gun install.log install.log.syslog
jawed jaweed text1
text1.bak text2 text2.bak
topi urdu
==-> STICKY BIT PERMISSIONS [root@localhost ~]# ls -l /root/urdu total 0 [root@localhost ~]# mv topi urdu [root@localhost ~]# ls -l /root/urdu total 8 drwxr-xr-x 2 root root 4096 Mar 22 15:08 topi [root@localhost ~]# chmod 1770 /root/urdu/topi [root@localhost ~]# ls -l /root/urdu total 8 drwxrwx--T 2 root root 4096 Mar 22 15:08 topi ==> FOR REMOVING STICKY BIT PERMISSIONS [root@localhost ~]# chmod 770 /root/urdu/topi [root@localhost ~]# ls -l /root/urdu total 8 drwxrwx--- 2 root root 4096 Mar 22 15:08 topi ==-> OWNERSHIP TO USER [root@localhost ~]# touch /root/urdu/topi/text4 [root@localhost ~]# ls -l /root/urdu/topi total 8 -rw-r--r-- 1 root root 0 Mar 22 19:49 text4 [root@localhost ~]# chown mogni /root/urdu/topi/text4 [root@localhost ~]# ls -l /root/urdu/topi total 4 -rw-r--r-- 1 mogni root 0 Mar 22 19:50 text4 ==-> OWNERSHIP TO GROUP [root@localhost ~]# groupadd -g 6000 doctors [root@localhost home]# useradd -u 6002 -g doctors user1 [root@localhost home]# ls katiya user1 [root@localhost home]# id user1 uid=6002(user1) gid=6000(doctors) groups=6000(doctors) [root@localhost ~]# ls /root/urdu/topi doc text4 [root@localhost ~]# touch /root/urdu/topi/text7 [root@localhost ~]# ls /root/urdu/topi doc text4 text7 [root@localhost ~]# ls -l /root/urdu/topi total 12 -rw-r--r-- 1 root root 0 Mar 22 19:59 doc -rw-r--r-- 1 mogni root 0 Mar 22 19:50 text4 -rw-r--r-- 1 root root 0 Mar 22 20:14 text7 [root@localhost ~]# chgrp doctors /root/urdu/topi/text7
[root@localhost ~]# total 12 -rw-r--r-- 1 root -rw-r--r-- 1 mogni -rw-r--r-- 1 root
ls -l /root/urdu/topi root 0 Mar 22 19:59 doc root 0 Mar 22 19:50 text4 doctors 0 Mar 22 20:14 text7
==->EFFICTIVE USERID (user can't change passwd) [root@localhost ~]# ls -l /usr/bin/passwd -r-s--x--x 1 root root 19336 Sep 7 2004 /usr/bin/passwd(show in red) [root@localhost ~]# chmod u-s /usr/bin/passwd [root@localhost ~]# ls -l /usr/bin/passwd -r-x--x--x 1 root root 19336 Sep 7 2004 /usr/bin/passwd(show in green) _______________________________________________________________________ ____ 21=-> CREATING USERS [root@localhost ~]# useradd jawed [root@localhost ~]# useradd jabbar [root@localhost ~]# useradd shajeeh [root@localhost ~]# passwd jawed Changing password for user jawed. New UNIX password: BAD PASSWORD: it's WAY too short Retype new UNIX password: passwd: all authentication tokens updated successfully. [root@localhost ~]# passwd jabbar Changing password for user jabbar. New UNIX password: BAD PASSWORD: it's WAY too short Retype new UNIX password: passwd: all authentication tokens updated successfully. [root@localhost ~]# passwd shajeeh Changing password for user shajeeh. New UNIX password: BAD PASSWORD: it's WAY too short Retype new UNIX password: passwd: all authentication tokens updated successfully. [root@localhost ~]# ls /home=-> USERS ROOT DIR jabbar jawed shajeeh [root@localhost ~]# id jawed uid=503(jawed) gid=503(jawed) groups=503(jawed) [root@localhost ~]# id jabbar uid=504(jabbar) gid=504(jabbar) groups=504(jabbar) [root@localhost ~]# id shajeeh uid=505(shajeeh) gid=505(shajeeh) groups=505(shajeeh) [root@localhost ~]# cat /etc/passwd root:x:0:0:root:/root:/bin/bash jawed:x:503:503::/home/jawed:/bin/bash jabbar:x:504:504::/home/jabbar:/bin/bash shajeeh:x:505:505::/home/shajeeh:/bin/bash [root@localhost ~]# cat /etc/gshadow
jawed:!:: jabbar:!:: shajeeh:!:: =-> COMMAND FOR ENCREPTTED PASSWD OF USERS [root@localhost ~]# cat /etc/shadow jabbar:$1$GjWCoPJ.$RNlKT0XvbYJTmWOYzvqzo0:13228:0:99999:7::: shajeeh:$1$CuY6L6rI$1MJq4BtNDKBFkRWBKKq/v.:13228:0:99999:7::: =-> IT SHOWS ALL LOGGED USERS [root@localhost ~]# users jabbar jawed root root shajeeh [root@localhost ~]# who jabbar tty1 Mar 21 18:28 jawed tty2 Mar 21 18:29 shajeeh tty3 Mar 21 18:29 root :0 Mar 21 17:56 root pts/1 Mar 21 18:06 (:0.0) [root@localhost ~]# w 18:31:27 up 37 min, 5 users, load average: 0.15, 0.13, USER TTY FROM LOGIN@ IDLE JCPU jabbar tty1 18:28 2:36 0.09s jawed tty2 18:29 2:18 0.07s shajeeh tty3 18:29 2:03 0.07s root :0 17:56 ?xdm? 4:43 /usr/bin/gnome-session root pts/1 :0.0 18:06 0.00s 0.53s =-->FOR SEARCHING A USER
0.21 PCPU 0.09s 0.07s 0.07s 1.80s
WHAT -bash -bash -bash
0.03s w
[root@localhost ~]# adduser jabbar [root@localhost ~]# passwd jabbar Changing password for user jabbar. New UNIX password: BAD PASSWORD: it does not contain enough DIFFERENT characters Retype new UNIX password: passwd: all authentication tokens updated successfully. [root@localhost ~]# su - jabbar [jabbar@localhost ~]$ pwd /home/jabbar [jabbar@localhost ~]$ touch text1 text2 [jabbar@localhost ~]$ ls text1 text2 [jabbar@localhost ~]$ exit logout [root@localhost ~]# find / -user jabbar find: /proc/2953/task/2953/fd/4: No such file or directory /home/jabbar /home/jabbar/.bash_history /home/jabbar/text1 /home/jabbar/text2 /home/jabbar/.bash_profile /home/jabbar/.gtkrc /home/jabbar/.bash_logout
/home/jabbar/.bashrc /var/spool/mail/jabbar ==->METHOD TWO<-== [root@localhost ~]# find /home -user jabbar /home/jabbar /home/jabbar/.bash_history /home/jabbar/text1 /home/jabbar/text2 /home/jabbar/.bash_profile /home/jabbar/.gtkrc /home/jabbar/.bash_logout /home/jabbar/.bashrc _______________________________________________________________________ ______ =->DELITING USERS [root@localhost ~]# userdel jawed userdel: user jawed is currently logged in | \|/ IT MEANS USER IS LOGGED IN IT CAN'T DELETE [root@localhost ~]# userdel jawed [root@localhost ~]# id jawed id: jawed: No such user =-> REMOVE USER WITH DIR [root@localhost ~]# userdel -r jabbar [root@localhost ~]# ls /home jawed shajeeh =->CREATING GROUP WITH USERS [root@localhost ~]# groupadd account [root@localhost ~]# useradd idris [root@localhost ~]# passwd idris Changing password for user idris. New UNIX password: BAD PASSWORD: it's WAY too short Retype new UNIX password: passwd: all authentication tokens updated successfully. ==-> ADDING USER INTO GROUP [root@localhost ~]# usermod -G account idris [root@localhost ~]# cat /etc/group account:x:507:idris ==-> ADDING A USER IN GROUP BY ANOTHER METHOD [root@localhost ~]# useradd -u 5001 -g mami katiya [root@localhost ~]# id katiya uid=5001(katiya) gid=5000(mami) groups=5000(mami) GROUP NAME DIR.NAME | | [root@localhost home]# useradd -u 5005 -g mami -d /usr/saba -m -s /bin/bash mogni | | | | | | USER GROUP DIR MAKE |_SHARE USERNAME +[root@localhost home]# id mogni uid=5005(mogni) gid=5000(mami) groups=5000(mami)
==->METHOD TWO [root@localhost ~]# cat /etc/gshadow account:!::idris =--> RENAMING GROUP [root@localhost ~]# groupmod -n sequrity account [root@localhost ~]# cat /etc/group sequrity:x:507:idris =--> DELETING GROUP [root@localhost ~]# groupdel sequrity [root@localhost ~]# cat /etc/group _______________________________o_o_o_o_-o-o-o-oo_o_o_o___________________ ==-> DATE AND TIME [root@localhost ~]# date Tue Mar 21 19:39:08 IST 2006 [root@localhost ~]# clock Tue 21 Mar 2006 07:39:18 PM IST -0.029170 seconds [root@localhost ~]# cal March 2006 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 [root@localhost ~]# _______________________________________________________________________ _____ ==-> CREATING A WEL COME BANNER [root@localhost ~]# vi /etc/motd ##########ATIQUE KHAN LATIF KHAN WEL COMES YOU########### esc :wq [root@localhost ~]# cat /etc/motd ##########ATIQUE KHAN LATIF KHAN WEL COMES YOU########### _______________________________################________________________ _____ ==->HISTORY COMMANDS [root@localhost ~]# history |less [root@localhost ~]# last shajeeh shajeeh tty3 Tue Mar 21 18:29 - 18:33 (00:04) wtmp begins Thu Mar 16 15:03:46 2006 [root@localhost ~]# finger shajeeh Login: shajeeh Name: (null) Directory: /home/shajeeh Shell: /bin/bash Last login Tue Mar 21 18:29 (IST) on tty3 No mail. No Plan. ==-> SWITCH USER ACCOUNT [root@localhost ~]# su - idris [idris@localhost ~]$ pwd /home/idris
[idris@localhost ~]$ su - root Password: [root@localhost ~]# pwd /root ==->METHOD TWO [root@localhost ~]# su - idris [idris@localhost ~]$ su Password: [root@localhost ~]# pwd /root _______________________________________________________________________ ______ ==-> GETTING HELP BY USING MAN,INFO man (1) - format and display the on-line manual pages man (7) - macros to format man pages [root@localhost ~]# man cat [root@localhost ~]# man -k mkdir mkdir (1) - make directories mkdir (2) - create a directory mkdirhier (1x) - makes a directory hierarchy [root@localhost ~]# man -f ls ls (1) - list directory contents [root@localhost ~]# whatis passwd passwd (1) - update a user's authentication tokens(s) passwd (5) - password file [root@localhost ~]# man 5 passwd ==-> (q)FOR EXIT _______________________________________________________________________ _____ ==-> FOR SEARCHING A FILE AND DIRECTORY THROUGH locate or slocate [root@localhost ~]# mkdir urdu [root@localhost ~]# locate urdu [root@localhost ~]# updatedb You have new mail in /var/spool/mail/root [root@localhost ~]# locate urdu /root/urdu /root/urdu [root@localhost ~]# slocate urdu /root/urdu /root/urdu [root@localhost ~]# whatis updatedb updatedb (1) - update the slocate database [root@localhost ~]# cat /etc/updatedb.conf # To enable the updatedb in cron, set DAILY_UPDATE to yes DAILY_UPDATE=no ==-> (if u type YES no need to type updatedb command) PRUNEFS="sysfs selinuxfs usbdevfs devpts NFS nfs afs sfs proc smbfs cifs autofs auto iso9660 udf"PRUNEPATHS="/tmp /usr/tmp /var/tmp /afs /net /sfs /selinux /udev /mnt/floppy" export PRUNEFS export PRUNEPATHS _______________________________________________________________________ ______ ==->COLOUR OF FILESYSTEMS TYPE Blue
=
directories
Black = files Green = for executable files Red = for zip file L.blue = for symbolic files (similar) [root@localhost jawed]# ls text1 text2.gz text3.gz text4 text5 yahoo | | | | | | black black(exc) red black l.blue blue [root@localhost jawed]# ln -s text4 text5 [root@localhost jawed]# ls text1 text2.gz text3.gz text4 text5 yahoo [root@localhost jawed]# cat text4 [root@localhost jawed]# cat > text4 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ########################## $$$$$$$$$$$$$$$$$$$$$$$$ %%%%%%%%%%%%%%%%%%%%%%%% ^^^^^^^^^^^^^^^^^^^^^^^ &&&&&&&&&&&&&&&&&&&&&&&& [root@localhost jawed]# ls text1 text2.gz text3.gz text4 text5 yahoo [root@localhost jawed]# cattext5 bash: cattext5: command not found [root@localhost jawed]# cat text5 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ########################## $$$$$$$$$$$$$$$$$$$$$$$$ %%%%%%%%%%%%%%%%%%%%%%%% ^^^^^^^^^^^^^^^^^^^^^^^ &&&&&&&&&&&&&&&&&&&&&&&& _______________________________________________________________________ ____ ==-> "ALIASES" FOR MAKING SHORTCUT COMMANDS [root@localhost ~]# alias c=clear [root@localhost ~]# alias mk=mkdir [root@localhost ~]# mk jawed _______________________________________________________________________ ____ ==-> PROCESS pstree (1) - display a tree of processes root@localhost ~]# pstree init─┬─apmd ├─atd ├─bonobo-activati ├─clock-applet ├─crond ├─cups-config-dae ├─cupsd ├─2*[dbus-daemon-1] ├─dbus-launch ├─eggcups ├─events/0─┬─aio/0 │ ├─kblockd/0 │ ├─khelper │ └─2*[pdflush] ├─gam_server ├─gconfd-2
├─gdm-binary───gdm-binary─┬─X │ └─gnome-session ├─gedit ├─gnome-keyring-d ├─gnome-panel ├─gnome-settings├─gnome-terminal─┬─bash───pstree │ └─gnome-pty-helpe ├─gnome-vfs-daemo ├─gnome-volume-ma ├─gpm ├─hald ├─kapmd ├─khubd ├─2*[kjournald] ├─klogd ├─kseriod ├─ksoftirqd/0 ├─kswapd0 ├─lockd ├─mapping-daemon ├─metacity ├─6*[mingetty] ├─mixer_applet2 ├─nautilus ├─8*[nfsd] ├─notification-ar ├─pam-panel-icon───pam_timestamp_c ├─portmap ├─rhn-applet-gui ├─rpc.idmapd ├─rpc.mountd ├─rpc.rquotad ├─rpc.statd ├─rpciod ├─scsi_eh_0 ├─2*[sendmail] ├─smartd ├─ssh-agent ├─sshd ├─syslogd ├─udevd ├─usb-storage ├─wnck-applet ├─xfs └─xinetd _______________________________________________________________________ _____ :--=> VIEWING PROCESS [root@localhost ~]# ps -alx _______________________________________________________________________ _____ :--=> PROCESS MONITORING [root@localhost ~]# top =--> KILL THE PROCESS OF SERVICE [root@localhost ~]# kill 1766 (portmap) =-> METHOD TWO
[root@localhost ~]# kill 0 1766 (portmap) _______________________________________________________________________ _____ ==-> TWO METHODS FOR COPYING CD(linux cd) --->METHOD ONE [root@localhost ~]# eject [root@localhost ~]# mount /media/cdrom mount: block device /dev/hda is write-protected, mounting read-only [root@localhost ~]# cp -r /media/cdrom/* /jawed [root@localhost ~]# ls jawed autorun README-de.html README-hi.html README-ta.html text3.gz EULA README-en README-it.html README-zh_CN.html text4 GPL README-en.html README-ja.html README-zh_TW.html text5 images README-es.html README-ko.html RedHat yahoo isolinux README-fr.html README-pa.html text1 README-bn.html README-gu.html README-pt_BR.html text2.gz [root@localhost ~]# umount /media/cdrom [root@localhost ~]# eject _______________________________________________________________________ ______ --->METHOD TWO FOR DUMPING [root@localhost ~]# mkdir jawed [root@localhost ~]# dd if=/dev/cdrom of=/root/jawed/disk1.iso [root@localhost ~]# dd if=/dev/cdrom of=/root/jawed/disk1.iso 329432+0 records in 329432+0 records out [root@localhost ~]# ls jawed disk1.iso [root@localhost ~]# eject SAME FOR DISK 2/3/4