Professional Documents
Culture Documents
Unix Commands
Unix Commands
Unix Commands
Look
in /bin, /usr/bin, /sbin, /tmp and /boot. What do you see?
Q:
now apply 'ls' command to see the newly created 'Unix' directory along with
other files and directories present in the home directory (excluding hidden
ones, for including hidden in the list we apply 'ls -a')$ ls
Desktop Documents examples.desktop Music Public Unix
docs
Downloads help
Pictures Templates Videos
$ ls
A B C r
here we have applied two more commands 'pwd' and 'ls' (which are already
explained above) to know about present working directory and list contents in it.
now we apply 'cat' commnd on file 'r' to read its contents$ cat r
aaaaaaaa
bbbbbbbb
cccccccc
Now we will look in /bin, /usr/bin, /sbin, /tmp and /boot using 'ls' command$ ls /bin
bash
bunzip2
busybox
bzcat
bzcmp
bzdiff
bzegrep
bzexe
bzfgrep
bzgrep
bzip2
bzip2recover
bzless
bzmore
cat
chacl
chgrp
chmod
chown
chvt
cp
cpio
dash
date
dbus-cleanup-sockets
dbus-daemon
dbus-uuidgen
dd
fgconsole
fgrep
findmnt
fuser
fusermount
getfacl
grep
gunzip
gzexe
gzip
hostname
ip
kbd_mode
kill
kmod
less
lessecho
lessfile
lesskey
lesspipe
ln
loadkeys
login
loginctl
lowntfs-3g
ls
lsblk
lsmod
nc
nc.openbsd
netcat
netstat
nisdomainname
ntfs-3g
ntfs-3g.probe
ntfs-3g.secaudit
ntfs-3g.usermap
ntfscat
ntfsck
ntfscluster
ntfscmp
ntfsdump_logfile
ntfsfix
ntfsinfo
ntfsls
ntfsmftalloc
ntfsmove
ntfstruncate
ntfswipe
open
openvt
pidof
ping
ping6
plymouth
plymouth-ups.-br.
sed
setfacl
setfont
setupcon
sh
sh.distrib
sleep
ss
static-sh
stty
su
sync
tailf
tar
tempfile
touch
true
udevadm
ulockmgr_server
umount
uname
uncompress
unicode_start
vdir
vmmouse_detect
which
whiptail
ypdomainname
df
dir
dmesg
dnsdomainname
domainname
dumpkeys
echo
ed
egrep
false
mkdir
mknod
mktemp
more
mount
mountpoint
mt
mt-gnu
mv
nano
r
ps
pwd
rbash
readlink
red
rm
rmdir
rnano
running-in-cntr.
un-parts
zcat
zcmp
zdiff
zegrep
zfgrep
zforce
zgrep
zless
zmore
znew
$ ls /usr/bin
[
2to3
2to3-2.7
2to3-3.4
a2p
aconnect
acpi_listen
glib-compile-schemas
gnome-calculator
gnome-character-map
gnome-contacts
gnome-disk-image-mounter
gnome-disks
gnome-file-share-properties
mk_modmap
sha512sum
mkzftree
shasum
mlabel
shotwell
mlocate
showconsolefont
mmcli
showfont
mmd
showkey
mmount
showrgb
...
...
...
...
alsaloop
alsamixer
alsaucm
amidi
gnome-keyring-daemon
gnome-language-selector
gnome-power-statistics
gnome-screensaver
mplayer
mrd
mren
mscompress
signon-ui
simple-scan
size
skill
...
...
...
...
ginstall-in.
gio-quer.
gipddecode
gkbd-kbd.
glib-c.rsrcs
mkfifo
mkfontdir
mkfontscale
mkisofs
mkmanifest
sha1pass
sha1sum
sha224sum
sha256sum
sha384sum
zjsdecode
zlib-flate
zsoelim
$ ls /sbin
acpi_available fstrim-all
agetty
gdisk
alsa
getcap
mkfs
mkfs.bfs
mkfs.cramfs
rmmod
route
rtacct
udevd
umount.udisks2
unix_chkpwd
...
ethtool
fatlabel
fdisk
...
iw
iwconfig
iwevent
ntfsundelete
on_ac_power
pam_tally
fsfreeze
fstab-decode
fstrim
mii-tool
mkdosfs
mke2fs
resize2fs
resolvconf
restart
$ ls /tmp
config-err-pHHDuF
OSL_PIPE_1000_SingleOfficeIPC_763a7bc0aefa8a1414c76a98f6fc7535
luzku5fv.tmp
unity_support_test.0
$ ls /boot
abi-3.19.0-25-generic initrd.img-3.19.0-25-generic System.map-3.19.0-25generic
abi-3.19.0-30-generic initrd.img-3.19.0-30-generic System.map-3.19.0-30generic
config-3.19.0-25-generic memtest86+.bin
vmlinuz-3.19.0-25-generic
config-3.19.0-30-generic memtest86+.elf
vmlinuz-3.19.0-30-generic
grub
memtest86+_multiboot.bin
Q: Firstlistthefilesinthedirectory.
Copyonefiletoanotherfile
Lookatthecontentofonefilefromthetop
Lookatthecontentofonefilefromthebottom
Checkiftwofilesareidentical.
Deleteafile
Makeatestdirectory
Movecoupleoffilestoit.
Removetestdirectory.
Makefivenewdirectoriesoneinsidetheotherlike
level1/level2/level3/level4/level5inonecommand.
Moveafiletotheinnermostdirectory.
Copyafiletoyourhomedirectory
Answer:
Wewillagainstartfromthehomedirectory.Firstweuse
'ls'commandtolistfilesinthehomedirectory
$ls
$pwd
/home/rrony
'cp' command to copy a file 'r' to a file 's' (before executing this command we
need to create 'r' file)$ cat > r
AAAAAAAA
BBBBBBBB
CCCCCCCC
DDDDDDDD
EEEEEEEE
FFFFFFFF
GGGGGGGG
HHHHHHHH
-------WWWWWWWW
XXXXXXXX
YYYYYYYY
ZZZZZZZZ
$ cp r s
$ cat s
AAAAAAAA
BBBBBBBB
CCCCCCCC
DDDDDDDD
EEEEEEEE
FFFFFFFF
GGGGGGGG
HHHHHHHH
-------WWWWWWWW
XXXXXXXX
YYYYYYYY
ZZZZZZZZ
'head -n' to look at the contents of first n lines of a file$ head -5 r
AAAAAAAA
BBBBBBBB
CCCCCCCC
DDDDDDDD
EEEEEEEE
'mv' command to move files 'y' and 'z' (must be created first) in the current
directory to the directory 'test'$>y
$>z
$ ls
Desktop Documents examples.desktop Music Public s Templates Unix Videos z
docs
Downloads help
Pictures
r t
test y
$ mv y z test
$ ls
Desktop Documents examples.desktop Music Public s Templates Unix Videos
docs
Downloads help
Pictures
r t
test
$ cd test
$ pwd
/home/rrony/test
$ ls
y z
'rmdir' command to remove the 'test' directory (but files 'y' and 'z' should be
removed first, as 'rmdir' cannot remove a non-empty directory)$ rm y z
$ cd ..
$ ls
Desktop Documents examples.desktop Music Public s Templates Unix Videos
docs
Downloads help
Pictures
r t
test
$ rmdir test
Desktop Documents examples.desktop Music Public s Templates Unix
docs
Downloads help
Pictures
r t
Videos
here 'cd ..' command is used to go back one level up to make sure we are in the parent
directory of the directory 'test'. This is because, to remove a directory it is necessary
to be in the parent directory or above.
'mkdir -p' command to make five new directories one inside the other like
level1/level2/level3/level4/level5 in one shot$ mkdir -p level1/level2/level3/level4/level5
$ ls
Desktop Documents examples.desktop level1 Pictures r t
u Videos
docs
Downloads help
Music Public s Templates Unix
$ mv r level1/level2/level3/level4/level5
Desktop Documents examples.desktop level1 Pictures s Templates Unix
docs
Downloads help
Music Public t u
Videos
$ cd level1/level2/level3/level4/level5
/home/rrony/level1/level2/level3/level4/level5
$ ls
r
'cp' command to copy a file 'r1' in the current directory to the home directory.
to do this, first we create the 'r1' file using '>' command$ > r1
$ ls
r r1
then,
$ cp r1 ../../../../..
$ cd
$ pwd
/home/rrony
$ ls
Desktop Documents examples.desktop level1 Pictures r1 t
u Videos
docs
Downloads help
Music Public s Templates Unix
Q: Explain the architecture of Unix operation system with the help of a neat diagram.
Answer:
The Unix operating system is made up of three parts; the kernel, the shell and the
programs.
Commands and Utilities: The highest level is utilities, which provides utility
functions. There are various cammand and utilities which we use in our day to day
activities, i.e., cp, mv, cat and grep etc.
Shell: The next level is the shell, which acts as the interface between user and kernel ,
interpreting user commands, passing them to kernel and starting applications.
Kernel: The kernel is the heart of the operating system-a collection of programs
mostly written in C, which communicate with the hrarware directly. It is that part of
the UNIX system that is loaded into memory when the system is booted. It manages
the system resources, allocates time between users and processes, decides process
priorities and performs other tasks which you wouldn't like to boter about. Other
programs (applications) also access the services of the kernel through a set of
finctions called system calls. The kernel is in fact the operating system-a program's
gateway to the computer's resources.
________________