List of Unix Shell Commands
List of Unix Shell Commands
mention below:
Basic.
Intermediate.
Advanced.
1. Basic Unix Shell Commands
a. Listing files (ls) – ‘ls’ command lists all the files in a directory.
Syntax- ls -<option> directory_name
Example-ls test
option Description
ls -a To list all files with the hidden files starting with ‘.’
ls -ls list with the long format with the file size
b. Creating & Viewing Files – ‘cat command can be used to create the file or view the
contents of the file.
Syntax –cat >filename
Example – cat > test1.dat – will create a file and wait for the input to be written into the file.
cat filname – will display the contents of the file on the screen.
c. Deleting Files -‘ rm’ command deletes a file from the directory.
Syntax-rm filename
Tag Description
Option Description
-type c Returns true if the file being searched is of type c( if c = ‘f’ means it is a file; if it ‘d’,
means it is a directory)
Example – If someone wants to search for file names ‘test1’ in the directory, he should give
a command like –
find –type f –name test1 /abi/sand
– This command will give all test1 file in /abi/sand directory
c. chown – change ownership of the file. Sometimes someone wants to change the file owner
so that someone working on that file can access that file. Only the file owner has the right to
change the file ownership.
Syntax:chown [owner] [file]
Example: Change the owner of test1 to user name ‘aaggasa’, assuming that the current user
currently owns it
> chown aaggasa test1
d. chgrp: change the group ownership of the file. This command is used to change the group
to which the file belongs. Only the file owner has the right to change the file ownership.
Syntax:chgrp [group] [file]
Example: Change the group of test1 to group2, assuming the current user currently owns it.
> chgrp group2 test1
e. Head: Unix gives us this command-line utility to extract the first part of the file. It writes
the result on standard output.
Syntax –head <option> <filename>
Option Description
Option Description
Option Description
Option Description