Unix Commands: Whoami Who Mkdir
Unix Commands: Whoami Who Mkdir
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