unix - oum students from maldives · pdf filels • ls -- listing file and directories...
TRANSCRIPT
Command List• ls
• mkdir
• mv
• chmod
• groupadd
• hostname
• kill
• head
• top
• compress/uncompress
• pwd
• Cat
• find
• chown
• useradd
• id
• ioscan
• sar
• cd
• more
• grep
• chgrp
• passwd
• mount
• dmesg
• netstat
• tar
• rm
• cp
• touch
• su
• uname
• ps
• tail
• ifconfig
Saturday, October 23, 2010
ls
• ls -- listing file and directories
• Most Commonly used options are:
• - a Listing all entries, including whose names begin with a period (.) are not listed
• - l List in long format
• - F After each file name, put one slash (/) if the file directory or an asterisk (*) if the file is executive.
• EXAMPLE
• ls -alF
Saturday, October 23, 2010
pwd
• pwd -- Show current directory
• Most Commonly used options are:
• -L Display the logical current working directory.
• -P Display the physical current working directory (all symbolic links resolved).
• EXAMPLE
• pwd [-L | -P]
Saturday, October 23, 2010
cd
• Changing Working directories
• Can use with absolute path and relative paths
• Using without any argument will redirect to User’s HOME directory
• EXAMPLE
• cd Desktop
Saturday, October 23, 2010
rm
• Removing files or directories
• OPTIONs
• -f Force each file or directory to be removed without prompting for confirmation, regardless of the permissions of the entry
• -i Write a prompt to standard error requesting confirmation before removing each entry. This option ignores any previous occurrence of the -f option
• EXAMPLE
• rm myFile
Saturday, October 23, 2010
mkdir
• Create a directory
• EXAMPLE
• mkdir myFolder
• mkdir /Users/xinuosx/Desktop/myFolder
Saturday, October 23, 2010
rmdir
• Remove a directory
• Can only remove if directory is empty.
• EXAMPLE
• rmdir myFolder
• rmdir OfficeDocuments
• rmdir: OfficeDocuments: Directory not empty
Saturday, October 23, 2010
cat
• cat - concatenate, copy, print files
• Cat reads each file in a sequence and writes it on the standard output.
• Thus cat file prints file on the default standard output device.
• EXAMPLE
• cat file1 file2 > file3
• (concatenate file1 and file2, and place the result in the file3)
Saturday, October 23, 2010
more
• Display the contents of a file one page at a time
• EXAMPLE
• more filename
Saturday, October 23, 2010
cp
• Copy file and directory subtrees.
• EXAMPLE
• 1. Copy file1 to new or existing new_file,
• cp file1 new_file
• 2. Copy file1 to existing directory
• cp file1 destination_directory
• 3. To create a zero-length file,
• cp /dev/null file
Saturday, October 23, 2010
mv
• Move or Rename file and directories
• EXAMPLE
• 1. Move file1 to new or existing file,
• mv file1 new_file
• 2. Move file1 to existing directory
• cp file1 destination_directory
• 3. Rename a file in the current directory,
• mv old_filename new_filename
Saturday, October 23, 2010
grep
• Search a file for a pattern
• EXAMPLE
• To search a file named address containing the following entries,
• Mohamed Nasheed Mulee Aage
• Mohamed Waheed Hilaaleege
• Maumoon A Gayoom Theemuge
• The command: grep Maumoon address
• prints:
• Maumoon A Gayoom Theemuge
Saturday, October 23, 2010
touch
• Update access, modification, and /or change times of file
• Usually, touch is used to create a new file.
• EXAMPLE
• To create a zero-length file, use
• touch Wataniya
Saturday, October 23, 2010
chmod
• Change file mode access permission.
• SYNOPSIS
• chown numeric_mode file..
• EXAMPLE
• To change the access permission of file1 to 664
• chmod 664 file1
Saturday, October 23, 2010
chown, chgrp
• Change file owner of group
• SYNOPSIS
• chown [-R] owner[:group] file..
• EXAMPLE
• The following command searches the directory design_notes and changes each file in that directory to owner mark and group
• chown -R mark: users design_note
Saturday, October 23, 2010
SUDO
• First man: Make me a sandwich.
• Second man: What? Make it yourself.
• First man: Sudo make me a sandwich.
• Second man: Okay ...
Saturday, October 23, 2010
su
• Change User
• SYNOPSIS
• su [-] [username]
• EXAMPLE
• The following command will change user and user’s environment variable
• su - zameem
• The following command will only change user’s permission
• su zameem
Saturday, October 23, 2010
groupadd
• Add a new group to the system
• SYNOPSIS
• groupadd [-g gid] grpup
• EXAMPLE
• Add the group projectx to etc/group file with the group iDD 117.
• groupadd - g 117 projectx
Saturday, October 23, 2010
useradd
• Add a new user login to the system
• SYNOPSIS
• useradd [-u uid] [-g gid] [-d dir] [-s shell] [c - cooment] [-m] login
• EXAMPLE
• Add the user xinuosx to the system with a UID of 222, base directory /user/xinuosx, sbin/csh as its default shell, and a primary group of staff
• useradd -u 222 -g staff /user/xinuosx -m -s /sbin/csh xinuosx
Saturday, October 23, 2010
passwd
• Change login password and associated attributes
• EXAMPLE
• To Change the password of user xinuosx , use
• passwd xinuosx
Saturday, October 23, 2010
uname
• Display information about computer system
• EXAMPE
• uname - a
• Darwin Mohamed-Faisals-iMac.local 10.4.0 Darwin Kernel Version 10.4.0: Fri Apr 23 18:28:53 PDT 2010; root:xnu-1504.7.4~1/RELEASE_I386 i386
Saturday, October 23, 2010
hostname
• set or display name of current host system
• EXAMPE
• The command hostname may produce the output like;
• Mohamed-Faisals-iMac
• which means the host name is Mohamed-Faisals-iMac
Saturday, October 23, 2010
id
• Print user and group IDs and mames
• EXAMPE
• To Display the current user and group data, use
• id
• which produce
• uid=501(xinuosx) gid=20(staff) groups=20(staff)
Saturday, October 23, 2010
mount
• Display the already mounted file system
• EXAMPE
• The command mount may display
• /dev/disk0s2 on / (hfs, local, journaled)
• devfs on /dev (devfs, local, nobrowse)
Saturday, October 23, 2010
ps
• Report process status
• The most commonly used options of ps are:
• -e select all process
• -f show common user, pid, ppidm cpu, stime, tty, time and args in that order
• EXAMPE
• Generate a full listing of all process currently running on your machine, use;
• ps - ef
Saturday, October 23, 2010
kill
• Send a signal to a process; terminate a process
• SYNOPSIS:
• kill - signum pid
• EXAMPLE
• UID PID PPID C STIME TTY TIME CMD
• 0 1 0 0 4:17.82 ?? 4:19.89 /sbin/launchd
• 0 10 1 0 0:01.73 ?? 0:24.34 /usr/libexec/kextd
• 0 11 1 0 0:24.42 ?? 1:06.88 /usr/sbin/DirectoryService
• 0 12 1 0 0:02.43 ?? 0:03.94 /usr/sbin/notifyd
Saturday, October 23, 2010
dmesg
• Collect system diagnostic message to from error log
• EXAMPE
• dmesg is mainly used to display the current memory usage.
Saturday, October 23, 2010
ifconfig
• Configure network interface parameters
• EXAMPE
• The command ifconfig lan1 may outputen1:flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500 ether 04:1e:64:f1:fe:a6 inet6 fe80::61e:64ff:fef1:fea6%en1 prefixlen 64 scopeid 0x6 inet 192.168.1.100 netmask 0xffffff00 broadcast 192.168.1.255 media: <unknown subtype> status: active
Saturday, October 23, 2010
sar
• System activity reporter
• EXAMPE
• Watch CPU activity evolve for 5 seconds.
• sar 1 5 or sar -u 1 5
• Report buffer activity
• sar -b 1 5
• Report activity for each block device, eg disk or tape drive;
• sar -d 1 5
Saturday, October 23, 2010
tar
• Tar is used to archive file
• EXAMPLE
• To archive file1, file2 and file3 into file.tar, use
• tar -cvf file.tar file1 file2 file3
• To display the contents of a archived file.tar, use
• tar -cvf file.tar
• To unachieved a archived file.tar, use
• tar -xvf file.tar
Saturday, October 23, 2010
compress/uncompress
• Compress and expand data
• EXAMPLE
• Compress the file name zenith and print compression information to the terminal
• compress -v zenith
• Undo the compression by typing either of following commands;
• uncompress zenith.Z
• compress -d zenith.Z
Saturday, October 23, 2010
VIEsc Switch between input mode and input mode and command mode
a Insert after current character
i Insert before current character
s Replace current character
dd Drop a line
o Insert new line after cursor
O Insert new line before cursor
x Remove current character
h/l Move left/right
j/k Move down/up
:w Save
:q Exit
ctr+b Roll back on screen
Ctr+f Roll forward one screen
Saturday, October 23, 2010