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

Basic Commands

The document discusses various Linux utilities for directory operations, file handling, text processing, disk utilities, backups and programmable text processing. It covers utilities like pwd, ls, cd, mkdir, rmdir, cat, cp, mv, rm, sort, ln, unlink, head, tail, find, more, w, nl, grep, egrep, fgrep, uniq, chmod, paste, cut, join, tee, cmp, diff, who, du, df, sed and awk.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Basic Commands

The document discusses various Linux utilities for directory operations, file handling, text processing, disk utilities, backups and programmable text processing. It covers utilities like pwd, ls, cd, mkdir, rmdir, cat, cp, mv, rm, sort, ln, unlink, head, tail, find, more, w, nl, grep, egrep, fgrep, uniq, chmod, paste, cut, join, tee, cmp, diff, who, du, df, sed and awk.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 17

Directory Related Utilities

1. pwd: It is used to print the full path of the present working directory starting from the root.

2. mkdir: It is used to create directory(ies), if they do not exist.

3. ls: It is used to list information about the files of the current directory by default (or) a specified
directory.
a. This command lists only the viewable contents of the directory

b. This command is used to print a larger list with all the permissions, users and owner
names

c. This command is used to print the hidden files that start with ‘.’ in the directory

4. cd: It is used to change the directory to the home directory by default (or) to a specified directory
5. rmdir: It is used to remove directory(ies) only if they are empty.
FILE HANDLING AND TEXT PROCESSING
1. cat: It is used to concatenate files and print on the standard output
a. cat > 2.txt: Creates a new file and write content to it

b. cat 2.txt: Prints the content of the file on standard output

c. cat >> 2.txt: Used to append extra content to the file

2. cp: It is sued to copy files or directories from a source to a destination in the file system.

3. mv: It is used to move a file from one location to another or to rename a file.

4. rm: It is used to remove specified files or directories.


5. sort: It is used to sort the content of a given file and prints it on the standard output
a. Sorting content based on numbers

b. Sorting content based on characters

6. ln –s: It is used to create symbolic links between two files

7. unlink: It is used to remove the symbolic links between files

8. head: It is used to print the specified number of lines of content of a file from the starting
9. tail: It is used to print the specified number of lines of content of a file from the bottom.

10. find: It is used to find files or directories in a specified directory and of a specified name
expression

11. more: It is used for paging through text one screen full at a time.

12. w: It is used to display information about the users currently on the machine, and their processes.
13. nl: It is used to write each file to standard output with line numbers added.

14. grep: It searches for a pattern in the given files

Example file :

a. –wn options are used to restricts matching to whole words only with line numbers

b. To display only those lines in a file thatdon’t match, use the -v option
15. egrep: It is used to search for extended regular expression patterns

16. fgrep: It is used to search for fixed strings in the specified files

17. uniq: The uniq utility displays a file with all of its identical adjacent lines replaced by a
singleoccurrence of the repeated line
a. filter out duplicate adjacent lines

b. display a count with the lines

c. ignore first field of each line.


18. chmod: It is used to change user’s, group’s and owner’s read, write and execute permissions of a
file or directory
a. Changing user permissions

b. Changing group permissions

c. Changing owner permissions

19. paste: It is used to parallel merge or join two files by outputing lines consisting of each line
separated by tabdelimiter.

20. cut: It is used for cutting out the sections from each line and displaying on standard output.
Example file :

a. –b option to cut specific bytes of each line in a file. We need to mention bytes followed
by commands.

b. –c option to specify the columns to print in each line of a file.

c. –f option is used to print the specified field number and the –d option specifies the
delimiter to separate the fields
21. join: It is used to join the lines of two files based on a common field.

22. tee: It is used to read from standard input and write to standard output and files
a. Without any options

b. –a command it used to append the standard input to a file rather than overwriting

23. cmp: It compares two files byte by byte and returns at which byte the files first differ
24. diff: It is used to compare two files and display a list of editing changes that would convert the
first file into the second file. It displays three kinds of editing changes: ‘a’ adding lines, ‘c’
changing lines and ‘d’ deleting lines
DISK UTITLITIES, BACKUP AND OTHER UTILITIES
1. who: It is used to print the information about users who are currently logged in.

2. du: It is used to summarize disk usage of the set of files, recursively for directories.

3. df: It displays the amount of disk space available on the file system containing each file name
argument. If not file name is give, the space available on all currently mounted file systems is
shown.

4. sed: The stream editor utility sed scans one or more files and performs an editing action on all of
the lines that match a particular condition.
a. Substituting text: Substituting first character with a space in each line

b. Deleting text: Deleting only those lines that contain the word ‘a’

c. Inserting text:

d. Replacing text:
PROGRAMMABLE TEXT PROCESSING
awk is a programmable text-processing utility that scans the lines of its input and performs
actions on every line that matches a particular criterion
a. Accessing individual files:

b. Begin and End

c. Operators

d. Variables
e. Control Structures

f. Extended regular expressions

g. Condition Ranges
h. Field Separators

i. Built-In functions

You might also like