Professional Documents
Culture Documents
UNIX
UNIX
File Mgmt.
# cat test
4
5
# file test
5. Touch cmd can create an empty file and update time stamp
# touch test1
# touch test{21,22,23}
# touch test-{1,2,3}.log
# touch {1,2,3}.log
# rm test1
# rm {1,2,3}.log
# rm *.log
1. To make directory
# mkdir chn
# mkdir chn{11,12,13}
# mkdir -p universe/world/india/TN/chn/nsn
# tree universe
# cd chn
# pwd
6. To go to parent directory.
# cd ..
7. To go to 4 level up
# cd ../../../../
# cd -
# cd
# cd ~
# rmdir chn
# ls -a <--- To list files/dires present in current dir including hidden object. -a is all
# ls -R universe
# ls -i test
# ls -l test
# ls -l /etc
# du -sh /etc <--- List specific dir. size in human readable format.
--------------------------------------------------------------
# df -h /boot
# df -h /
# df -h /home
Compression/Uncompression Utilities:
1. gzip/gunzip/zcat
2. bzip2/bunzip2/bzcat
3. xz/unxz/xzcat
History Commands:
# !c
# !115
-----------------------------------------------------------------
Database Files:
4. /etc/resolv.conf <--- It holds default domain to search and nameserver i.e. DNS server IP
Addresses.
5. /etc/nsswitch.conf <--- It holds name server search wrt. local system or dns or nis or nisplus or
ldap.
Exer:
1. Add network system's HN and IP Address entry to local system in /etc/hosts file. Check
connectivity using name and IP Address.
# hostname nsnchennai
* It is set temp. If system is rebooted then the hostname mentioned in the file
/etc/sysconfig/network will be loaded by kernel.
3. To setup IP manually.
# system-config-network
4. To check IP Address
# ifconfig
# ifconfig eth0
# ip addr show
# ip route
* It is temp. set. If system is rebooted then IP Address will be loaded from "ifcfg-eth0" file.
# /etc/rc.d/init.d/network stop
# /etc/rc.d/init.d/network start
# /etc/rc.d/init.d/network restart
# /etc/rc.d/init.d/network status
------------------------------------------------------
usermod <-- To modify existing user a/c properties wrt. UID,GID,Home Dir., Login Shell etc.
groupmod <-- To modify group properties wrt. GID and Group Name
* We can add member to the group while user a/c creation using "useradd" cmd.
If user a/c exist then we can use "usermod" cmd. to add existing user to the group as its member.
Exer:
# useradd raj
# passwd raj
# finger loginname
# finger raj
# id loginname
# id raj
UID=1000
Comment=System Crasher
-c <-- Comment
5. Setup login shell /bin/ksh and comment "system analyst" to user a/c prabhakaran.
6. Rename user a/c "prabhakaran" to "karan" and rename its home dir.
# userdel james
12. Setup Minimum, Maximum and Warning days for user a/c raj.
Warning : 3 Days
# chage -m 1 -M 30 -W 3 raj
-m <-- Min
-M <-- Max
-W <-- Warn
# chage -E -1 raj
# groupadd tech
19. Add existing user a/c "raj" to group "tech" and "support"
* User a/c "raj" has its own group called "raj" which is his primary group. Groups "tech" and
"support" will be his secondary groups.
# groupdel support
# gpasswd research
# newgrp GroupName
# newgrp research
27. Change UserOwner to "raj" and GroupOwner to "support" for "/data" dir.
1. Read (r)
2. Write (w)
3. eXecute (x)
read --> 4
write --> 2
execute --> 1
* Umask --> It is filter used by system to calculate effective permissions to be applied to the file/dir.
while creating it.
Exer.:
------------------------------------------------------------------
# vi /etc/inittab
id:3:initdefault:
---------------------------------------------------------------------
Exer:
* Go to "single user mode" from Grub menu. System will enter in shell without "root" user
password.
Execute,
# passwd root
then
# exit
* System will boot into default runlevel, now login by new password.
---------------------------------------------------------------------
Managing Processes
# ps
# ps -a <--- all
# ps -e <-- Every
# ps -ef
# kill -l
( Default kill signal is 15 i.e. SIGTERM, Forcible kill signal is
9 i.e. SIGKILL.)
# kill <PID>
# kill 123
# Kill -9 <PID>
# renice -n 10 -p 3787
# top
---------------------------------------------------------------
Managing Services
To check all installed services status ( enabled or disabled )
----------------------------------------------------------------