UNIX Basic UNIX Command
Command List ls mkdir mv chmod groupadd hostname kill head top compress/ uncompress pwd Cat find chown useradd id ioscan pdf sar cd more grep chgrp passwd mount dmesg netstat tar rm cp touch su uname ps tail ifconfig
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. ls -alf
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). pwd [-L -P]
cd Changing Working directories Can use with absolute path and relative paths Using without any argument will redirect to User s HOME directory cd Desktop
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 rm myfile
mkdir Create a directory mkdir myfolder mkdir /Users/xinuosx/Desktop/myFolder
rmdir Remove a directory Can only remove if directory is empty. rmdir myfolder rmdir OfficeDocuments rmdir: OfficeDocuments: Directory not empty
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. cat file1 file2 > file3 (concatenate file1 and file2, and place the result in the file3)
more Display the contents of a file one page at a time more filename
cp Copy file and directory subtrees. 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
mv Move or Rename file and directories 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
grep Search a file for a pattern To search a file named address containing the following entries, Mohamed Nasheed Mohamed Waheed Hilaaleege Maumoon A Gayoom Theemuge The command: grep Maumoon address prints: Maumoon A Gayoom Mulee Aage Theemuge
touch Update access, modification, and /or change times of file Usually, touch is used to create a new file. To create a zero-length file, use touch Wataniya
chmod Change file mode access permission. SYNOPSIS chown numeric_mode file.. To change the access permission of file1 to 664 chmod 664 file1
chown, chgrp Change file owner of group SYNOPSIS chown [-R] owner[:group] file.. 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
SUDO First man: Make me a sandwich. Second man: What? Make it yourself. First man: Sudo make me a sandwich. Second man: Okay...
su Change User SYNOPSIS su [-] [username] The following command will change user and user s environment variable su - zameem The following command will only change user s permission su zameem
groupadd Add a new group to the system SYNOPSIS groupadd [-g gid] grpup Add the group projectx to etc/group file with the group idd 117. groupadd - g 117 projectx
useradd Add a new user login to the system SYNOPSIS useradd [-u uid] [-g gid] [-d dir] [-s shell] [c - cooment] [-m] login 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
passwd Change login password and associated attributes To Change the password of user xinuosx, use passwd xinuosx
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
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
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)
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)
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
kill Send a signal to a process; terminate a process SYNOPSIS: kill - signum pid 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
dmesg Collect system diagnostic message to from error log EXAMPE dmesg is mainly used to display the current memory usage.
ifconfig Configure network interface parameters EXAMPE The command ifconfig lan1 may output en1: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
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
tar Tar is used to archive file 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
compress/uncompress Compress and expand data 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
VI Esc 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
Thank You