Please enable JavaScript.
Coggle requires JavaScript to display documents.
Important Commands - Coggle Diagram
Important Commands
-
vi
Vi IMproved, a programmer's text editor
vim [options] [file ..]
vim [options] -
vim [options] -t tag
vim [options] -q [errorfile]
+[num]
For the first file the cursor will be positioned on line "num". If "num" is missing, the cursor will be positioned on the last
line.
+/{pat}
For the first file the cursor will be positioned in the line with the first occurrence of {pat}.
grep
The grep filter searches a file for a particular pattern of characters, and displays all lines that contain that pattern.
grep -i "UNix" geekfile.txt
-i option enables to search for a string case insensitively in the give file. It matches the words like “UNIX”, “Unix”, “unix”.
-
sort
sort lines of text files
SORT command is used to sort a file, arranging the records in a particular order. By default, the sort command sorts file assuming the contents are ASCII. Using options in sort command, it can also be used to sort numerically
-
-
zip
zip [options] zipfile files_list
package and compress (archive) files
ZIP is a compression and file packaging utility for Unix. Each file is stored in single .zip
-
-
tar
an archiving utility
tar -czvf name-of-archive.tar.gz /path/to/directory-or-file
-c: Create an archive.
-z: Compress the archive with gzip.
-v: Display progress in the terminal while creating the archive, also known as “verbose” mode. The v is always optional in these commands, but it’s helpful.
-f: Allows you to specify the filename of the archive.
-
df
df [OPTION]... [FILE]...
The df command (short for disk free), is used to display information related to file systems about total space and available space.
df
If no file name is given, it displays the space available on all currently mounted file systems.
df /home/mandeep/test/test.cpp
if you specify particular file, then it will show mount information of that particular file.
cat
cat filename
Cat(concatenate) command is very frequently used in Linux. It reads data from the file and gives their content as output. It helps us to create, view, concatenate files. So let us see some frequently used cat commands.
-
less
less is a command that displays file contents or command output one page at a time in your terminal. less is most useful for viewing the content of large files or the results of commands that produce many lines of output. The content displayed by less can be navigated by entering keyboard shortcuts.
-
ps -ef | less
To view the output of another command with less, redirect the output from that command using a pipe
less -N your-file-name
To see line numbers on each line, use the -N option
tail
tail [OPTION]... [FILE]...
The tail command, as the name implies, print the last N number of data of the given input. By default it prints the last 10 lines of the specified files. If more than one file name is provided then data from each file is precedes by its file name.
-
- -n - --lines
- -c - --bytes
- -q - --quiet
- v - -- verbose
- f - -- follow
-
-
-q
tail -q state.txt capital.txt
It is used if more than 1 file is given. Because of this command, data from each file is not precedes by its file name.
-
-f
tail -f logfile
This option is mainly used by system administration to monitor the growth of the log files written by many Unix program as they are running.
-