0% found this document useful (0 votes)
44 views

Unix Commands: Whoami Who Mkdir

The document describes various Unix commands for file manipulation, directory navigation, permissions management and more. Key commands covered include ls to list files, mkdir to create directories, rm to delete files, cp to copy, mv to move, chmod to change permissions. The document provides examples of using each command and its typical syntax.

Uploaded by

Shitiz Sethi
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views

Unix Commands: Whoami Who Mkdir

The document describes various Unix commands for file manipulation, directory navigation, permissions management and more. Key commands covered include ls to list files, mkdir to create directories, rm to delete files, cp to copy, mv to move, chmod to change permissions. The document provides examples of using each command and its typical syntax.

Uploaded by

Shitiz Sethi
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 14

Unix Commands

 who am i
 Identifies user
 who
 All users who have logged in currently
 mkdir
 Create directory
 mkdir sample
 rmdir
 Remove directory
 rmdir sample

1
Unix Commands
 cd
 Change directory
 cd sample
 touch
 create empty file
 touch file1
 cat
 create file
 cat > file1
 cat file1
 cat file1 file2 > newfile

2
Unix Commands
 ls
 display contents of directory
 ls
 ls –a
 ls –l
 ls t*

3
Unix Commands
 cp
 Copy one file to another
 cp file1 file2
 rm
 Remove file
 rm sample
 rm –i
 rm –f
 rm –r
 mv
 Rename a file
 mv file1 file2

4
Unix Commands
 ln
 Create link for a file
 ln file1 file2
 date
 Display date and current time

5
Unix Commands
 $clear
 Clear the terminal screen
 Can also be achieved by command
 $tput clear
 $cal
 Display calendar of present month
 $cal
 $cal 1 2010
 $cal 2010
 $wc
 Compute word count (number of lines, words, characters)
 wc -l
 wc -w
 wc –c
6
Unix Commands
 $ls | wc
 Standard output of ls passed as input to wc connected
through pipe (|)
 $script
 Records terminal session to file typescript
 Type exit to stop logging results
 $ispell
 Apply spell-check on a file
 $pwd
 Print working directory
 /home/ritu/documents
 $echo $HOME
 /home/bob
Unix Commands
 $bc
 Starts calculator
 $bc
 5+7
 12
 12 * 12
 144
 Type quit to exit

 $file
 Determine type of file
 $file sample
 sample: ASCII English text
File manipulation commands
 $split
 Split a file into smaller files
 Generates files of 1000 lines (default size)
 $split -10 sample
 Creates files xaa, xab, xac,...
 $split -10 sample part
 Creates files partaa, partab, partac,...
File manipulation commands
 $more
 Display file one screen at a time
 $more sample

 $head
 Display first 10 lines of a file
 $head -n 5 sample

 $tail
 Display last 10 lines of a file
 $tail -n 5 sample
File Comparison
 $cmp
 Compares files
 $cmp partaa partab
 partaa partab differ: byte 1, line 1
File Comparison
 $comm
 Compares files, displays what is common
 Requires sorted files as input

$comm sample1 sample2


sample1 sample2 moon
moon moon planet
planet star star
sun sun
File Permissions
 $ ls -l sample1
 -rw-r--r-- 1 deepti deepti 16 2010-02-03 12:54
sample1
 First column indicates file permissions:
 Read (r)
 Write (w)
 Execute (x)
 Permissions assigned to:
 User (u)
 Group (g)
 Others (o)
Using chmod to change file
permissions
 Use chmod command to change file permissions
 $chmod u+x sample1 #Assign execute permission to user
 $chmod g+w sample1 #Assign write permission to group
 $chmod a+rw sample1 #Assign read-write permission to all
 $chmod a=r sample1 #Keep only read permission for all
 $chmod 777 sample1 #Assign rwx permission for all

You might also like