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

OS Commands

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

OS Commands

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

OS Commands

1- PWD: show Current Directory (Present working directory)


2- LS: List all files and directories in your current directory
3- LS -al: List detailed information about files
4- Cd /directoryname (ex: cd /bin): change directory to another
5- cd: move to home
6- cd /: move to root
7- cat > filename: create a new file and add the content then press ctrl+d to return to command line
8- cat filename: show content of the file

9- cat file1 file2 > newfile: merge 2 files in one file


10- rm filename: remove a file
11- MV: Renaming the file or directory
12- mkdir directoryname: Create a directory
13- rmdir directoryname: remove a directory
14- Man commandname (Man history): gives information about this command
15- History: shows all the commands that you have used.
16- pr -x filename (pr -3 file1): divides the data into 3 columns.
17- pr -h “Header” filename: Making header for file.
18- pr -n filename: denotes all the lines in the file with numbers
19- Chmod (764) filename: changing the permissions of file by ABSOLUTE(NUMERIC)
METHOD 20- Chmod (g+w) filename: changing the permissions of file by SYMBOLIC METHOD
21- ls -al > listing: redirect the output

22- echo “welcome” >> filename: add more content to an existing file
23- cat Filename | less: Pipe is a command in Linux that lets you use two or more
commands 24- cat filename | grep (word): search a particular information in the file
25- cat filename | grep -v (word or letter): Shows all the lines that do
not match the searched string

26- cat filename | grep -i (word or letter): Match both (upper and
lower) case

27- cat filename | grep -c (word or letter): Displays only the count
of matching lines

28- cat filename | grep -n (word or letter): Shows the matching line and
its number

29- Sort filename: sorting the contents of a file alphabetically


30- Sort -r filename: reverse sorting
31- Sort -n filename: sort numerically
32- cat filename | grep -i a | sort -r: filtered output of the first command is given to the
next 33- Variablename=vale: creating a new variable

34- echo $VARIABLENAME: determine value of a variable


35- unset variablename: remove a Variable from the system

You might also like