In this blog post, we’ll take a look at 229 of the most useful Linux commands.
We’ll also discuss how to use them, and provide some examples on how they can be used in real-world scenarios. So, if you’re looking to learn more about Linux commands, read on!
1. admin Command
admin command is a source code control system command, used to create and administer SCCS files.
Some examples admin of Command:
admin
2. alias Command
alias command instructs the shell to replace one string with another string while executing the commands.
Some examples of alias Command:
To print all aliases
alias -p
Remove aliases
unalias [alias name]
Create new aliases
alias [alias name]
3. ar Command
ar command is used to create, modify and extract the files from archives. r syntax is used to create archive files, while q is used to delete archive files.
Some examples of ar Command:
Ar command follows this
ar [OPTIONS] archive_name member_files
Lets say you have an ssl certificate yesterblog.crt that you want to put in an archive folder you want to create with ar command, named certificates. You use the command below.
ar r yesterblog.crt *certificates
4. apt Command
apt is a command-line utility for installing, updating, removing, and otherwise managing deb packages on unix
Some examples of apt Command:
To update files on your server use the command below. Choose appropraite command, depending on whether you are logged in as root or sudo.
apt update
sudo apt update
To download upgrade files from repository automatically, use the commands below, depending on whether you are root or sudo.
apt-get upgrade
sudo apt-get upgrade
To update downloaded upgrades.
apt upgrade
sudo apt upgrade
5. asa Command
The asa command asa writes its input files to standard output,
Some examples of asa Command:
To view file (created by a program using FORTRAN-style carriage-control characters) on a terminal.
asa filename
formats the FORTRAN output of b.out and directs it to the printer.
b.out | asa | lp
6. at Command
at command is a command-line utility that is used to schedule a command to be executed at a particular time in the future. at Command is similar to cron job.
Unlike cron, at command does the job once, not repeatedly like cron.
Before you can use at command, you need to install the at command on your server, be it ubuntu or centos.
To install at command on ubuntu depending on sudo or root user.
apt-get install at
sudo apt-get install at
To install at command on centos, depending on sudo or root user.
yum install at
sudo yum install at
Some examples of at Command:
To view all at pending at commands
at -l
sudo at -l
Schedule a job to run on the coming Friday.
at Friday
Schedule a job to run on the coming Friday, 50 minutes later.
at Friday +50 minutes
Schedule a job to run on a particular date and time, lets say 14th February 2022, 4:55pm
at 4:55pm 021422
Schedule system shutdown 5 hrs from now.
echo "shutdown -h now" | at now +5hrs
To delete an at command,
use the command below to list all running at commands and get the job number on the list.
at -l
Use any command below to delete at command.
at -r [job number]
atrm [job number]
7. awk Command
awk Command is used for generating reports and data manipulation. awk command can also be used for arithmetic and string operations, and conditionals and loops.
awk command can format output lines, and transform data files to produce formatted reports.
Also, it can be used to scan file line by line, perform actions on matched lines, and split each input line into fields.
Lets say you have a .txt file on your server called users.txt, and you wanted to print out the content of the .txt file, you can use awk command.
Some examples of awk Command:
awk 'print' users.txt
Output
yester ceo account 60606
blog worker account 3029
ordinary sales 540404
8. basename Command
basename Command prints the last element of a file path.
Some examples of basename Command:
basename filepath
9. bash Command
The bash command is a command line interface for the GNU operating system. It is a shell that provides both interactive and non-interactive use.
The bash command has been around since the early days of Unix, but it was not until Version 4.0 that it became widely used.
The bash command is often used to automate tasks in Linux and Unix-like operating systems, such as running a program or script at regular intervals, sending commands to another computer on a network, or updating files with another computer on the network.
Some examples of bash Command:
bash [options] [file]
10. batch Command
batch Command similar to htop command, is used to read commands from standard input or a specified file and execute them when system load levels permit
To use batch Command, type batch in command line:
batch
11. bc Command
bc Command also known as basic calculator command, is a command used to do basic arithmetic calculations. some of its options
Options:
- h (help) – get help
- i (interactive) : Enforce interactive mode
- l (mathematics library or mathlib) : Define standard math library
- w (warn) : Give warnings to POSIX bc
- s (standard) : process exactly the POSIX bc language
- q (quiet) Stop showing welcome print
- v (version) : Show bc calculator version
basic calculator command supports many types of calculations:
- Arithmetic operators
- Increment or Decrement operators
- Assignment operators
- Comparison or Relational operators
- Logical or Boolean operators
- Math functions
- Conditional statements
- Iterative statements
Some examples of bc Command:
1. Basic arithmetic:
$ echo "2+2" | bc
4
$ echo "10-5" | bc
5
$ echo "3*4" | bc
12
$ echo "8/4" | bc
2
2. Using variables:
$ echo "a=4" | bc
4
$ echo "b=6" | bc
6
$ echo "a*b" | bc
24
3. Performing square root and exponentiation:
$ echo "sqrt(4)" | bc
2
$ echo "10^3" | bc
1000
4. Using functions:
$ echo "define add(a,b) { return a+b }" | bc
$ echo "add(4,5)" | bc
9
5. Using if
statements:
$ echo "if (1 > 2) print 1 else print 0" | bc
0
6. Using while
loops:
$ echo "i=0; while (i<10) { print i; i=i+1 }" | bc
0
1
2
3
4
5
6
7
8
9
12. bg Command
The bg
command in Linux is used to background a process that was previously put into the foreground. This allows you to continue working in the terminal while the process continues to run in the background.
The basic syntax for the bg
command is:
bg [job_id]
Where job_id
is the ID of the process you want to background. If you do not specify a job ID, the bg
command will background the most recently stopped or suspended process.
Here are a few examples:
- To background the process with ID
1234
:
bg 1234
13. break Command
In Linux and Unix-like systems, the break
command is used to exit from a loop. It can be used in both shell scripts and programming languages like C and C++ that have loop constructs such as for
, while
, and do-while
.
When used in a shell script, break
terminates the execution of the current loop and resumes execution at the next command after the loop.
Here’s an example of using break
in a for
loop in a shell script:
for i in {1..10}; do
if [ $i -eq 5 ]; then
break
fi
echo $i
done
14. c99 Command
c99
is a command line utility for compiling C99 source code. C99 is a standard for the C programming language that was first published in 1999 and introduced several new features and improvements to the language, such as variable-length arrays and new data types.
Here’s an example of using c99
to compile a C99 source code file called myprogram.c
into an executable file called myprogram
:
c99 myprogram.c -o myprogram
15. cal Command
The cal
command in Linux is used to display a calendar for the current month or a specified month and year. The command is typically used to quickly view the days of the month and can be useful for scheduling and planning tasks.
The basic syntax for the cal
command is:
cal [options] [[month] year]
Where options
are any command line options you want to pass to the command and [[month] year]
are the month and year for which you want to display the calendar. If you do not specify a month and year, the calendar for the current month will be displayed.
Here are a few examples:
- To display the calendar for the current month:
cal
cal is a command-line utility used to print out calendar in the terminal.
16. cat Command
The “cat” command is a Linux command that is used to concatenate and display the contents of one or more files in the terminal. It stands for “concatenate,” and it is used to display the contents of a file, or to concatenate multiple files and display the output.
The basic syntax of the command is:
cat file1 file2 file3
17. cd Command
The cd
(change directory) command in Linux is used to change the current working directory of a terminal session. The current working directory is the directory that the terminal is currently “looking at” and where commands are executed.
Here are some examples of how to use the cd
command:
cd
: This command, used by itself, will take you to your home directory. For example, if your username is “john,” runningcd
will take you to the directory at/home/john/
.cd /
: This command will take you to the root directory of the file system. This is the top-level directory that contains all other directories and files on the system.
18. cflow Command
cflow Command analyzes the C, C++, yacc, lex, assembler, and object files and writes a chart of their external references to standard output.
Here are some examples of how to use the cflow
command:
cflow main.c
: This command will generate a call graph of the C program in the file main.c and display it on the terminal.cflow -b main.c
: This command will generate a call graph as before, but will also include macro expansions in the outputcflow -o graph.dot main.c
: This command will generate a call graph in the Graphviz’s dot format and save it to the file ‘graph.dot’cflow -n main.c
: This command will generate a call graph, but only include functions defined in the input file and exclude system functions
19. chgrp Command
The chgrp Command is a command that can be used to change the group ownership of a file or directory.
The chgrp Command is used to change the group ownership of a file or directory. It can be used to change the group ownership of files and directories in Linux, Mac OS X, and Unix-like operating systems.
The chgrp Command is also known as “chmod” in Unix-like operating systems.
Here are some examples of how to use the chgrp
command:
chgrp group file.txt
: This command will change the group ownership of the filefile.txt
togroup
.chgrp -R group dir
: This command will change the group ownership of the directorydir
and all the files and directories inside it togroup
chgrp -h symlink
: This command will change the group ownership of the symlink ‘symlink’ instead of the file or directory it points to
20. chmod Command
In Linux and other Unix-like operating systems, the chmod
command is used to change the permissions of a file or directory. The permissions determine who is able to read, write, and execute a file or list the contents of a directory.
The chmod
command takes two arguments: the permissions you want to set, and the file or directory whose permissions you want to change.
The permissions are specified using a combination of letters and numbers. There are three types of permissions that can be set: read (r
), write (w
), and execute (x
). These permissions can be set for three different classes of users: the file owner (u
), the members of the file’s group (g
), and all other users (o
).
To specify the permissions, you can use either letters or numbers. Here are some examples:
chmod u+x file.txt
– This gives the owner of the file execute permissions.chmod g-w file.txt
– This removes write permissions for the members of the file’s group.chmod o=r file.txt
– This sets read permissions for others.chmod 755 /path/to/directory
– This sets read, write and execute permissions for the owner and read and execute permissions for group and others.
See all examples of chmod Command
21. chown Command
The chown command (short for “change owner”) is a command used in Linux and Unix-based operating systems to change the ownership of a file or directory. The command takes two arguments: the first is the name of the user who will become the new owner of the file or directory, and the second is the file or directory whose ownership will be changed.
Here are some examples of how chown command can be used:
- To change the ownership of a file named file.txt to user named “yesterblog”:
chown yesterblog file.txt
22. chroot Command
The chroot
command is used in Linux to change the root directory for a running process and its children. This can be useful for running a program with a different filesystem environment than the host system.
Here are a few examples of how to use the chroot
command:
- To change the root directory of a command to a directory called
/newroot
, use the following command:
sudo chroot /newroot command
23. cksum Command
The cksum
command in Linux is used to calculate the cyclic redundancy check (CRC) and byte count of a file. The output of the command includes the CRC value, the byte count of the file, and the name of the file.
Here are a few examples of how to use the cksum
command:
- To calculate the CRC and byte count of a file called
file.txt
, use the following command:
cksum file.txt
24. clear Command
The clear
command is a command-line utility on Linux and other Unix-like operating systems that is used to clear the terminal screen. Here are a few examples of how to use the clear
command:
- To clear the terminal screen, simply type
clear
and press Enter.
$ clear
- You can also use the keyboard shortcut
Ctrl + L
to achieve the same result.
25. cmp Command
The cmp
command is a command-line utility on Linux and other Unix-like operating systems that is used to compare the contents of two files. It returns an exit status of 0 if the files are identical, and a non-zero exit status if the files are different. Here are a few examples of how to use the cmp
command:
- To compare the contents of two files, you can use the following syntax:
$ cmp file1 file2
- You can also compare the contents of two files and display the offset of the first byte that differs by using the
-l
option:
$ cmp -l file1 file2
26. comm Command
The comm
command is a command-line utility on Linux and other Unix-like operating systems that is used to compare the contents of two sorted files. It takes two files as input and produces three columns of output: lines unique to the first file, lines unique to the second file, and lines common to both files. Here are a few examples of how to use the comm
command:
- To compare the contents of two sorted files, you can use the following syntax:
$ comm file1 file2
- If you want to suppress the column of lines that are unique to the first file, you can use the
-1
option:
$ comm -1 file1 file2
27. command Command
he command
command is used in a Linux or Unix shell to run a specified command and bypass any function or alias that may be defined with the same name as the command being run. This can be useful in situations where you want to use the built-in version of a command rather than a function or alias that you have defined.
Here are some examples of how command
can be used:
- To run the built-in version of the
ls
command:
command ls
28. compress Command
Here are some examples of how to use the compress
command:
compress file.txt
: This command will compress the filefile.txt
and create a new file namedfile.txt.Z
. The original file will be kept, but its contents will be replaced with the compressed version.compress -v file.txt
: This command will compress the filefile.txt
and create a new file namedfile.txt.Z
and also displays the percentage reduction of the file size
The compress command is a new feature in the latest version of the Linux kernel. It compresses files and folders by removing unnecessary data.
The compress command is a new feature in the latest version of the Linux kernel. It compresses files and folders by removing unnecessary data. The compression ratio can be controlled with a number of options, such as -z option which will reduce file size by 50% without losing any information, or -9 option which will reduce file size by 90%.
The compress command can also be used to create archives that are compressed with gzip or bzip2 algorithms.
29. continue Command
The continue command is a shell programming command that allows you to continue the current line of code.
It can be used in many different ways, such as continuing a loop or continuing an if statement.
The continue command is often used in loops and if statements.
Here are some examples of how continue
can be used in different types of loops:
- In a
for
loop:
for i in {1..10}; do
if [ $i -eq 5 ]; then
continue
fi
echo $i
done
This script will print the numbers 1 through 10, but will skip the number 5.
30. cp Command
cp Command (copy Command), is a file system command that can be used to copy text from one file to another.
The cp command is a very useful tool for programmers and developers. It can be used to copy text from one file to another, or even between two different files.
The cp command is also useful for copying text from the terminal into a file.
- To copy a file to a different location:
cp file1.txt /path/to/destination
- To copy multiple files to a different location:
cp file1.txt file2.txt /path/to/destination
- To copy a directory and its contents to a different location:
cp -r directory1 /path/to/destination
31. crontab Command
Crontab is a command-line utility that allows users to schedule commands to be executed periodically. It can be used for scheduling tasks such as backups, sending email, and running scripts.
The crontab command can be used in Linux and Unix-like operating systems.
- To edit your crontab file, use the following command:
crontab -e
. This opens the crontab file in the default editor for you to add or edit scheduled tasks. - To list the current crontab tasks for the current user, use the following command:
crontab -l
. - To remove the current user’s crontab, use the following command:
crontab -r
. - To add a new task to the crontab, you can use the following command:
crontab -e
, then enter the task in the following format on a new line: * * * * * command - - - - - | | | | | | | | | ----- Day of week (0 - 7) (Sunday = both 0 and 7) | | | ------- Month (1 - 12) | | --------- Day of month (1 - 31) | ----------- Hour (0 - 23) ------------- Minute (0 - 59)
For example, the following command will run thescript.sh
file every day at 3:30am:30 3 * * * /path/to/script.sh
32. csplit Command
The csplit command is a powerful text proccessing tool that can be used to split a file into multiple files. It is often used by developers and programmers who need to split large files into smaller ones for easier management.
The csplit command can also be used in other ways, such as splitting text files into multiple smaller text files or splitting logfiles into smaller logs.
Some examples of csplit Command:
- To split a file into multiple smaller files based on a specific line number, use the following command:
csplit file.txt 10
This will split the file “file.txt” into multiple files, each containing 10 lines of the original file. The resulting files will be named “xx00”, “xx01”, etc. - To split a file into multiple smaller files based on a regular expression, use the following command:
csplit file.txt '/regex/'
This will split the file “file.txt” into multiple files based on the location of the regular expression “regex” in the file.
33. ctags Command
ctags Command is a C programming command, used to create a tags file.
Some examples of ctags Command:
- To generate a tags file for all source files in the current directory and its subdirectories, use the following command:
ctags -R .
This will recursively scan the directory for files and generate a “tags” file that can be used to navigate the source code. - To generate a tags file for a specific file, use the following command:
ctags filename.c
- To generate a tags file for specific language, use the following command:
ctags -R --languages=python
34. cut Command
cut Command is a shell programming command used to cut out selected fields of each line of a file.
Some examples of cut Command:
- Extract the first field (delimited by a tab character) from a file:
cut -f1 -d$'\t' file.txt
- Extract the second and third fields (delimited by a comma) from a file:
cut -f2,3 -d, file.txt
- Extract the first and last characters from each line of a file:
cut -c1,$ file.txt
35. cxref Command
cxref Command is a C programming category command used to generate a C-language program cross-reference table.
Some examples of cxref Command:
- To generate an HTML version of the documentation for a program called “myprog.c”:
cxref -html -output myprog.html myprog.c
- To generate a LaTeX version of the documentation for multiple C files “file1.c”, “file2.c”, “file3.c”:
cxref -latex -output myprog.tex file1.c file2.c file3.c
36. datamash Command
datamash is a command-line program which performs basic. numeric, textual and statistical operations on input textual data files.
Some examples of datamash Command:
- To calculate the sum, minimum, and maximum of the values in the second column of a CSV file:
datamash sum 1 min 2 max 2 < input.csv
- To group the data by the first column and calculate the mean of the values in the second column:
datamash --group 1 mean 2 < input.csv
37. date Command
date Command is used to write the date and time.
Some examples of date Command:
- To display the current date and time:
date
- To display the date in a specific format:
date +"%Y-%m-%d %T"
- To set the date and time to a specific value:
sudo date -s "2022-12-25 12:00:00"
38. dc Command
dc command in a linux command, used to evaluate arithmetic expressions, and evaluates expressions in the form of a postfix expression.
Some examples of date Command:
- To perform basic arithmetic operations:
echo "2 3 + p" | dc
This command will add 2 and 3 and print the result.
- To perform advanced calculations
echo "2 3 ^ p" | dc
This command will raise 2 to the power of 3 and print the result.
- To perform floating point calculations
echo "3 4 5 / * p" | dc
39. dd Command
dd Command is a filesystem command, used to convert and copy a file.
Some examples of dd Command:
- To create a backup of a hard drive:
sudo dd if=/dev/sda of=~/sda-backup.img bs=1M
This command will create an image of the entire hard drive at /dev/sda in the home directory as “sda-backup.img”
- To clone a hard drive to another hard drive
sudo dd if=/dev/sda of=/dev/sdb bs=1M conv=noerror
40. delta Command
delta Command is a source code control system command, used to make a delta (change) to a source code control system (SCCS) file
Some examples of delta Command:
- To create a delta file of two files
delta file1 file2 > delta.d
This command will create a delta file “delta.d” containing the difference between file1 and file2.
- To apply a delta file to an original file
delta -u originalfile < delta.d > newfile
41. df Command
df (disk free) Command is used to report and display the amount of available disk space for file systems on which the invoking user has appropriate read access.
Some examples of df Command:
- o display disk usage of all file systems
df
- To display disk usage of a specific file system
df /dev/sda1
- To display disk usage in human-readable format
df -h
42. diff Command
diff Command is a text processing command used to compare two files.
Some examples of diff Command:
- To compare the contents of two files:
diff file1.txt file2.txt
This command will compare the contents of file1.txt and file2.txt and display the differences between them.
- To compare the contents of two directories:
diff -r dir1 dir2
43. dir Command
dir (directory) Command is a command in various computer operating systems used for computer file and directory listing.
Some examples of dir Command:
- To list the files and directories in the current directory, you can use the command
dir
without any arguments:
dir
- To list the files and directories in a specific directory, you can provide the path to the directory as an argument:
dir /path/to/directory
44. dirname Command
The dirname (directory name) Command is a type of dir (directory) Command. It is used to return the directory portion of a pathname
Some examples of dirname Command:
- To display the parent directory of a given file:
dirname /path/to/file.txt
- To display the parent directory of a given directory:
dirname /path/to/directory
- To use the output of one command as the input to the
dirname
command:
dirname $(pwd)
45. dot Command
dot Command is a shell programming Command, used to execute commands in the current environment.
Some examples of dot Command:
- To create a PNG image of a graph specified in a plain text file:
dot -Tpng input.dot -o output.png
- To create a PDF of a graph specified in a plain text file:
dot -Tpdf input.dot -o output.pdf
- To create a SVG image of a graph specified in a plain text file:
dot -Tsvg input.dot -o output.svg
46. du Command
du Command is a filesystem Command, used to estimate file space usage.
Some examples of du Command:
- To display the sizes of all files and directories in the current directory:
du
- To display the sizes of all files and directories in a specific directory:
du /path/to/directory
- To recursively display the sizes of all files and directories within a specific directory:
du -h /path/to/directory
47. echo Command
echo Command is a shell programming command that outputs the strings that are passed to it as arguments, in standard output.
Some examples of echo Command:
- Print a simple string of text:
echo "Hello, World!"
- Print the value of an environment variable, such as the current working directory:
echo $PWD
- Concatenate strings and print the result:
echo "Hello, " "World!"
48. ed Command
ed Command is a text processing Command, used to launch the ed standard text editor.
Some examples of ed Command:
- Open a file named “file.txt” and begin editing it:
ed file.txt
- Add a new line of text to the file:
a
This is a new line of text.
.
w
- Print the contents of the file:
1,$p
49. env Command
env Command is used to list environment variables or invoke a command in a modified environment.
Some examples of env Command:
- Display all environment variables:
env
- Display the value of a specific environment variable:
env | grep HOME
- Run a command with a modified environment:
env PATH="/usr/local/bin:$PATH" command
50. eval Command
eval Command is a shell programming Command is construct command by concatenating arguments.
Some examples of eval Command:
- Execute a command stored in a variable:
cmd="ls -l"
eval $cmd
- Concatenate variables and execute the resulting command:
var1="ls"
var2="-l"
eval $var1 $var2
- Execute commands stored in an array:
cmds=("ls -l" "pwd" "whoami")
for cmd in "${cmds[@]}"; do
eval $cmd
done
51. ex Command
ex Command is a text editor, and the line-editor mode of vi.
Some examples of ex Command:
- Open a file named “file.txt” and begin editing it with
vi
command
vi file.txt
- Then enter the command mode and type
:e file2.txt
to edit another file in the same session
:e file2.txt
- To open multiple files in the same session, you can use
:args
command
:args file1.txt file2.txt file3.txt
- Copy a line from a file and paste it to another file in the same session
:1,3 co 5
52. exec Command
exec command is used for manipulating file-descriptors (FD), creating output and error logging within scripts with a minimal change.
Some examples of exec Command:
- Open a new shell in the current terminal:
exec bash
- Open a new instance of
vi
:
exec vi file.txt
- Run a Python script and replace the current process with it:
exec python script.py
53. exit Command
exit Command is a shell programming Command used to cause the shell to exit.
Some examples of exit Command:
- Exit the current shell or terminal session:
exit
- Exit a script with a specific exit code:
exit 0
- Exit a script when a certain condition is met:
if [ condition ]; then
exit 1
fi
54. expand Command
expand command is a text processing Command used to extract a single file or a group of files from a compressed file.
Some examples of expand Command:
- Convert tabs to spaces in a file named “file.txt”
expand file.txt
- Convert tabs to a specific number of spaces, e.g. 4
expand -t 4 file.txt
- Convert tabs to spaces in the input stream, e.g. when using
cat
cat file.txt | expand
55. export Command
export Command is used to set the export attribute for variables.
Some examples of export Command:
- Export a new environment variable:
export VAR="value"
- Export multiple environment variables at once:
export VAR1="value1" VAR2="value2"
- Use
export
in a script to make a variable available to commands run within the script:
#!/bin/bash
export VAR="value"
command1
command2
56. expr Command
expr Command is a shell programming Command, used to valuate arguments as an expression.
Some examples of expr Command:
- Perform arithmetic operations:
expr 5 + 2
expr 10 - 3
expr 3 \* 4
expr 20 / 5
- Perform comparisons:
expr 5 \> 2
expr 5 \< 2
expr 5 \== 5
- Perform string operations:
expr "hello" : '.*\(...\)'
expr length "hello"
57. false Command
false Command is a shell programming Command, used to return false value.
Some examples of false Command:
- To create a simple shell script that always exits with a failure status:
#!/bin/bash
false
- To check the exit status of a command, and take action based on whether it succeeded or failed:
command
if [ $? -eq 0 ]; then
echo "Command succeeded"
else
echo "Command failed"
fi
- To use “false” command as a placeholder when a command must be executed but no action is required:
command || false
58. fc Command
fc Command is used to process the command history list
Some examples of fc Command:
- To list the last 10 commands in your history:
fc -l -10
- To list all commands in your history containing the word “command”:
fc -l | grep command
- To edit the last command that you entered:
fc
59. fg Command
fg (fore ground) Command is a process management Command, used to run jobs in the foreground.
Some examples of fg Command:
- To bring the most recent background process to the foreground:
fg
- To bring a specific background process to the foreground by its job ID:
fg %1
In this example, the process with the job ID of 1 will be brought to the foreground.
- To bring a specific background process to the foreground by its command name:
fg %command
60. file Command
file Command is a filesystem Command used to determine file type.
Some examples of file Command:
- To determine the type of a file:
file file.txt
This will return a string describing the type of the file, for example: “file.txt: ASCII text”
- To check multiple files at once:
file file1.txt file2.jpg file3.mp3
- To print detailed information about the file format
file -b -L --mime-type filename
61. find Command
find Command is a filesystem Command used to find files.
Some examples of find Command:
- To search for all files and directories in the current directory:
find .
- To search for all files with the .txt extension in the current directory and its subdirectories:
find . -name '*.txt'
- To search for all files that were modified in the last 24 hours:
find . -mtime -1
62. flex Command
flex Command is a C programming command, used to generate programs for lexical tasks.
Some examples of flex Command:
- Creating a simple lexer for a simple calculator:
%{
#include <stdio.h>
%}
%%
[0-9]+ { printf("number: %s\n", yytext); }
[ \t] ; /* ignore whitespace */
. { printf("unexpected character: %s\n", yytext); }
%%
int main(int argc, char* argv[]) {
yyparse();
return 0;
}
63. fold Command
fold Command is a text processing command, used to filter for folding lines.
Some examples of fold Command:
- Wrapping lines to a width of 80 characters:
fold -w 80 input.txt > output.txt
- Wrapping lines to a width of 40 characters and displaying the result on the screen:
fold -w 40 -s input.txt
64. fort77 Command
fort77 Command is a C Programming, for Fortran compiling.
Some examples of fort77 Command:
- Compile a FORTRAN 77 source file, “program.f” into an object file “program.o”:
fort77 -c program.f
- Compile and link a FORTRAN 77 source file, “program.f” into an executable file “program”:
fort77 program.f -o program
- Compile a FORTRAN 77 source file, “program.f” and specify include paths, for example, to include “-I/path/to/headers”:
fort77 -I/path/to/headers -c program.f
65. fortune Command
fortune Command is used to displays a random quotation.
Some examples of fortune Command:
- Display a random fortune to the terminal:
fortune
- Display a fortune from a specific file, for example from the fortunes-off file
fortune fortunes-off
- Display a fortune with a specific cookie file, for example from the “funny” category:
fortune funny
66. ftp Command
ftp (file transfer protocol) Command is used for internet file transfer between machines or programs.
Some examples of ftp Command:
- Connect to an FTP server and login as a user:
ftp ftp.example.com
You will be prompted for your username and password
- Connect to an FTP server with a specific username and password:
ftp ftp.example.com -u ftpusername -p ftppassword
67. fuser Command
fuser Command is a process Management Command, used to list process IDs of all processes that have one or more files open.
Some examples of fuser Command:
- Identify which process(es) are using a specific file:
fuser file.txt
- Identify which process(es) are using a specific file and display the command name of the process:
fuser -c file.txt
- Identify which process(es) are using a specific file system, for example, the /tmp file system
fuser -m /tmp
68. gawk Command
gawk Command is a text processing Command used for pattern scanning and processing language, GNU’s version of awk.
Some examples of gawk Command:
- Print the first field of each line in a file:
gawk '{print $1}' file.txt
- Print the second and third fields of each line, separated by a comma:
gawk '{print $2, $3}' file.txt
- Print the number of fields in each line:
gawk '{print NF}' file.txt
69. gencat Command
gencat (generate catalogue) Command is used to generate a formatted message catalog.
Some examples of gencat Command:
- Create a message catalog from a source file:
gencat messages.cat messages.po
- Update an existing message catalog with new translations from a source file:
gencat -u messages.cat messages.po
- Generate a message catalog and specify the output format:
gencat -f iso-2022-jp messages.cat messages.po
70. get Command
get Command is a source code control system command used to the get version of a source code control system file.
Some examples of get Command:
curl
command is used to transfer data from or to a server using various protocols such as HTTP, HTTPS, FTP, etc.
curl -O http://example.com/file.txt # download a file
wget
command is used to download files from the internet.
wget http://example.com/file.txt # download a file
scp
command is used to copy files between hosts on a network.
scp [email protected]:/path/to/file.txt . # copy file from remote host
71. getconf Command
getconf (get configuration) Command is used to get configuration values of installations.
Some examples of getconf Command:
- Display the system’s maximum number of open files:
getconf OPEN_MAX
- Display the system’s page size:
getconf PAGESIZE
- Display the system’s path name delimiter:
getconf PATH_MAX
72. getopts Command
getopts Command is a shell programming Command, used to parse utility options.
Some examples of getopts Command in bash script:
#!/bin/bash
while getopts ":a:b:" opt; do
case $opt in
a)
arg_a="$OPTARG"
;;
b)
arg_b="$OPTARG"
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
echo "arg_a: $arg_a"
echo "arg_b: $arg_b"
73. grep Command
grep Command is used to search for text pattern and strings, in a group of files.
Some examples of grep Command:
- Search for a specific string in a file:
grep "search_string" file.txt
- Search for a pattern in multiple files
grep "search_pattern" file1.txt file2.txt file3.txt
- Search for a pattern in all files in a directory recursively:
grep -r "search_pattern" /path/to/directory/
74. groupadd Command
groupadd Command is used to create and add a new group to terminal.
Some examples of groupadd Command:
- Create a new group:
groupadd newgroup
This command creates a new group called “newgroup” on the system.
- Create a new group with a specific GID(group id):
groupadd -g 1025 newgroup
This command creates a new group called “newgroup” with a GID of 1025.
- Create a new group and assign a password to it:
groupadd -p password newgroup
75. groupdel Command
groupdel Command is used to delete an existing group from terminal.
Some examples of groupdel Command:
- Delete an existing group:
groupdel existinggroup
76. groups Command
groups Command is used to list groups a user belongs to
Some examples of groups Command:
- Display the groups for the current user:
groups
- Display the groups for a specific user:
groups username
- Display the groups for multiple users
groups user1 user2 user3
77. hash Command
hash Command is used to remember or report utility locations.
Some examples of hash Command:
- To remember the full path of the
ls
command, you can run the following command:hash ls
- To display all commands that have been hashed, use the -l option:Copy code
hash -l
- You can also use -r option with hash command to clear the remembered path of a command
hash -r ls
- You can also use -d option with hash command to remove the remembered path of a command
hash -d ls
78. head Command
head Command is a text processing Command used to copy the first part of files.
Some examples of head Command:
- To display the first 10 lines of a file called “example.txt”, you can run the following command:
head example.txt
- To display the first 15 lines of the same file, you can use the -n option:
head -n 15 example.txt
- To display the first 20 lines of a file and also show the line number , you can use the -n and -v option:
head -n 20 -v example.txt
79. history Command
history Command is used to show history of all commands ever used on a terminal.
Some examples of history Command:
- To display the history of commands in the current terminal session, you can simply run the following command:
history
- To display the history of commands with line numbers, use the -n option:
history -n
- To display a specific number of previous commands from the history, use the -n option followed by a number. For example, to display the last 20 commands:
history 20
80. hostname Command
hostname is a networking command used to show the system’s host name.
Some examples of hostname Command:
- To display the current hostname of the system, you can simply run the following command:
hostname
- To set the hostname of the system, you can use the -s option followed by the new hostname. For example, to set the hostname to “my-server”:
hostname -s my-server
Note that this command will change the hostname for the current session, but the change will not persist after reboot.
81. htop Command
htop Command does the same thing on terminal, which task manager does on windows. htop Command shows terminal processes in real time, and the amount of system resources they are consuming.
Some examples of htop Command:
- To start htop and view the running processes and their usage, you can simply run the following command:
htop
82. iconv Command
iconv command converts the encoding of characters read from either standard input or the specified file from one coded character set to another and then writes the results to standard output.
Some examples of iconv Command:
- To convert a file from UTF-8 to ISO-8859-1, you can run the following command:
iconv -f UTF-8 -t ISO-8859-1 inputfile.txt -o outputfile.txt
- To convert a file from Shift-JIS to UTF-8, you can use the following command:
iconv -f Shift-JIS -t UTF-8 inputfile.txt -o outputfile.txt
83. id Command
id (identity) Command is used to return a users identity.
Some examples of id Command:
- To display information about the current user, simply type
id
and press enter:
$ id
uid=1000(jdoe) gid=1000(jdoe) groups=1000(jdoe),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),108(lxd)
- To display information about a specific user, provide the username as an argument to the command:
$ id jdoe
uid=1000(jdoe) gid=1000(jdoe) groups=1000(jdoe),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),108(lxd)
84. iostat Command
iostat Command is used to collect and show operating system storage input and output statistics.
Some examples of iostat Command:
- To display the average CPU utilization and disk usage statistics since the system was last booted, simply type
iostat
and press enter:
$ iostat
Linux 4.15.0-114-generic (jdoe-linux) 07/25/2023 _x86_64_ (8 CPU)
avg-cpu: %user %nice %system %iowait %steal %idle
5.67 0.00 3.33 0.33 0.00 90.67
Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn
sda 0.00 0.00 0.00 0 0
sdb 0.00 0.00 0.00 0 0
85. ipcrm Command
ipcrm command removes one or more message queues, semaphore sets, or shared memory identifiers
Some examples of ipcrm Command:
- To remove a shared memory segment identified by a specific ID:
$ ipcrm -m 1234
- To remove a message queue identified by a specific ID:
$ ipcrm -q 1234
- To remove a semaphore set identified by a specific ID:
$ ipcrm -s 1234
86. ipcs Command
ipcs is a Unix and Linux command to list System V InterProcess Communication System’s API kernel entities to stdout. It also report interprocess communication facilities status.
Some examples of ipcs Command:
- To display information about all shared memory segments on the system:
$ ipcs -m
------ Shared Memory Segments --------
key shmid owner perms bytes nattch status
0x00001234 0 root 600 32768 0
0x00005678 65537 jdoe 600 16384 0
- To display information about all message queues on the system:
$ ipcs -q
------ Message Queues --------
key msqid owner perms used-bytes messages
0x00001234 0 root 666 0 0
0x00005678 65537 jdoe 666 0 0
87. jobs Command
jobs Command display status of jobs in the current session
Some examples of jobs Command:
- To view a list of all background jobs, simply run “jobs” without any arguments:
$ jobs
- To bring a background job back to the foreground, you can use the “fg” command followed by the job number:
$ fg %3
- To send a background job to the background, you can use the “bg” command followed by the job number:
$ bg %2
88. join Command
join command provides us with the ability to merge two files together using a common field in each file as the link between related lines in the files.
Some examples of join Command:
- To join two files, file1.txt and file2.txt on the first field:
$ join file1.txt file2.txt
- To join two files, file1.txt and file2.txt on the second field:
$ join -1 2 -2 2 file1.txt file2.txt
- To join two files and use a different delimiter (e.g., “:”):
$ join -t : file1.txt file2.txt
89. kill Command
kill Command is a built-in command which is used to terminate processes.
Some examples of kill Command:
- To terminate a process by its PID (process ID), you can use the command:
$ kill PID
where “PID” is the process ID of the process you want to terminate.
- To terminate a process by its name, you can use the command
$ pkill process_name
90. last Command
last command is used to displays information about the last logged-in users.
Some examples of last Command:
- To view the last logged in users
$ last
- To show the last logins for a specific user
$ last username
91. less Command
less Command is a Linux utility that can be used to read the contents of a text file one page(one screen) at a time.
Some examples of less Command:
- To view a text file one page at a time, use the following command:
$ less file.txt
Where “file.txt” is the name of the file you want to view.
- To search for a specific word or phrase within a file:
$ less file.txt
/search-string
92. lex Command
lex Command is a C programming command used to generate programs for lexical tasks.
Some examples of lex Command:
- To generate a lexer from a lexer specification file “example.l”
$ lex example.l
This will output a C file called lex.yy.c, which contains the lexer code.
- To generate a lexer and specify the output file name.
$ lex example.l -o example_lexer
93. link Command
link Command is a filesystem utility used to call link function.
Some examples of link Command:
- To create a hard link to a file, use the following command:
$ ln original_file hard_link
Where “original_file” is the name of the existing file, and “hard_link” is the name of the new hard link.
- To create a symbolic link to a file:
$ ln -s original_file symbolic_link
94. ln Command
ln Command is a filesystem command-line utility for creating links between files.
Some examples of ln Command:
- To create a hard link to a file, use the following command:
$ ln original_file hard_link
Where “original_file” is the name of the existing file, and “hard_link” is the name of the new hard link.
- To create a symbolic link to a file:
$ ln -s original_file symbolic_link
95. locale Command
locale Command is a linux command used to get locale-specific information.
Some examples of locale Command:
- To display the current locale settings:
$ locale
- To display the current settings for a specific category, you can use the option “-k” and category name like this
$ locale -k LC_TIME
96. localedef Command
localedef Command is used to define locale environment.
Some examples of localedef Command:
- To create a new locale from a template file:
$ localedef -f UTF-8 -i template_file new_locale
Where “template_file” is the name of the file containing the locale definition, and “new_locale” is the name of the new locale.
- To modify an existing locale:
$ localedef -f UTF-8 -i existing_locale modified_locale
97. locate Command
locate command in Linux is used to find the files by name.
Some examples of locate Command:
- To find all files in the system that have the word “example” in their name:
locate -i example
- To find all files in the system that have the extension “.txt”:
locate -i .txt
98. logger Command
logger Command is a shell programming Command, used to log messages.
Some examples of logger Command:
- To log a message to the system’s default log file (typically /var/log/messages):
logger "this is a test message"
- To log a message to the system’s auth log file (typically /var/log/auth.log):
logger -p auth.notice "this is a test message"
99. login Command
login Command begins or initializes the user session environment from the user database, from the terminal.
Login Command:
login
100. logname Command
logname Command is used to return the user’s login name.
Logname Command:
logname
101. logout Command
logout command allows you to logout from your current session.
Some examples of logout Command:
logout
102. lp Command
lp Command is a text processing command used to send files to a printer.
Some examples of lp Command:
- To print a file named “file.txt” to the default printer:
lp file.txt
- To print a file named “file.txt” to a specific printer:
lp -d printer_name file.txt
103. ls Command
ls Command is a filesystem Command used to list directory contents.
Some examples of ls Command:
- To list the files and directories in the current directory:
ls
- To list the files and directories in a specific directory:
ls /path/to/directory
- To list the files and directories in a directory in a long format, showing details such as file permissions, owner, and size:
ls -l
104. m4 Command
m4 Command is used for macro processing.
Some examples of m4 Command:
- Define a macro named
greeting
and expand it in a file namedhello.txt
:
$ echo 'greeting(Hello, World!)' > hello.txt
$ m4 -Dgreeting='Hello, World!' hello.txt
Hello, World!
- Include the contents of a file named
header.m4
in the current file:
$ echo 'Hello, World!' > header.m4
$ echo 'include(header.m4)' > hello.txt
$ m4 hello.txt
Hello, World!
105. mailx Command
mailx Command is a linux command used for process messages.
Some examples of mailx Command:
- Send a simple email to an address:
$ echo 'This is the body of the email.' | mailx -s 'Hello, World!' [email protected]
This will send an email with the subject “Hello, World!” and the body “This is the body of the email.” to the email address [email protected]
- Send an email with attachment
$ echo 'This is the body of the email.' | mailx -s 'Hello, World!' -a file.txt [email protected]
106. make Command
make Command is a shell programming utility used to maintain, update, and regenerate groups of programs.
Some examples of make Command:
$ cat Makefile
CC = gcc
CFLAGS = -Wall -g
all: main.o func.o
$(CC) $(CFLAGS) -o myprogram main.o func.o
main.o: main.c
$(CC) $(CFLAGS) -c main.c
func.o: func.c
$(CC) $(CFLAGS) -c func.c
clean:
rm -f myprogram main.o func.o
$ make
107. man Command
man Command is used to display system documentation.
Some examples of man Command:
- View the manual page for the
ls
command:
$ man ls
This will display the manual page for the ls
command, which provides information on how to use ls
to list the contents of a directory, as well as information about the various options that can be used with ls
.
- Search for a keyword in all available manual pages:
$ man -K keyword
108. mesg Command
mesg Command is used to permit or deny messages.
Some examples of mesg Command:
- Allow other users to send messages to your terminal:
$ mesg y
This will set the terminal to allow other users to send messages to your terminal.
- Disallow other users to send messages to your terminal:
$ mesg n
109. mkdir Command
mkdir Command is a filesystem command, used make directories.
Some examples of mkdir Command:
- Create a new directory called “test” in the current directory:
mkdir test
- Create a new directory called “test” in the /home/ directory:
mkdir /home/test
110. mkfifo Command
mkfifo Command is a filesystem Command used to make FIFO special files.
Some examples of mkfifo Command:
- Create a named pipe called “mypipe”:
mkfifo mypipe
- Create a named pipe with a specific permission:
mkfifo -m 666 mypipe
The -m
option is used to specify the permission mode of the named pipe.
- Create multiple named pipes at once:
mkfifo pipe1 pipe2 pipe3
111. mktemp Command
mktemp Command is a filesystem Command used to create a temporary file or directory.
Some examples of mktemp Command:
- Create a temporary file with a unique name:
mktemp
This command will create a file in the default temporary directory (usually /tmp/) with a unique name such as /tmp/tmp.XXXXXXXXXX
.
- Create a temporary file with a specific prefix:
mktemp mytemp.XXXXXXXXXX
112. more Command
more Command displays files on a page-by-page basis
Some examples of more Command:
- Display the contents of a file called “file.txt”:
more file.txt
- Display the contents of a file called “file.txt” and search for a specific word:
more +/word file.txt
The +/
option is used to start the display at the first occurrence of the specified word.
- Display the contents of a file called “file.txt” and start displaying at a specific line number:
more +50 file.txt
113. mount Command
mount Command is a filesystem command, used to mount a file system.
Some examples of mount Command:
- Mount a file system located on the device /dev/sda1 to the mount point /mnt/:
mount /dev/sda1 /mnt/
- Mount a file system with specific options:
mount -t ext4 -o rw,noatime /dev/sda1 /mnt/
The -t
option is used to specify the file system type, the -o
option is used to specify the mount options.
- Mount a file system located on a remote host:
mount -t nfs -o rw,proto=tcp,port=2049 host:/ /mnt/
114. mtail Command
mtail command, as the name implies, print the last N number of data of the given input.
Some examples of mtail Command:
- Extract metrics from a log file and print them to the console:
mtail -logfile=access.log -progs=my_metrics.mtail
The -logfile
option is used to specify the log file from which metrics will be extracted, the -progs
option is used to specify the mtail program file that contains the metrics extraction rules.
- Extract metrics from a log file and export them to a Prometheus exporter:
mtail -logfile=access.log -progs=my_metrics.mtail -exporter=prometheus
The -exporter
option is used to specify the exporter to which metrics will be exported.
- Extract metrics from multiple log files and export them to a Prometheus exporter:
mtail -logfile=access.log -logfile=error.log -progs=my_metrics.mtail -exporter=prometheus
115. mv Command
mv command that moves one or more files or directories from one place to another. If both filenames are on the same filesystem, this results in a simple file rename; otherwise the file content is copied to the new location and the old file is removed.
Some examples of mv Command:
- Move a file called “file.txt” from the current directory to a directory called “documents”:
mv file.txt documents/
- Rename a file called “file.txt” to “newfile.txt” in the current directory:
mv file.txt newfile.txt
- Move multiple files to a directory:
mv file1.txt file2.txt file3.txt documents/
116. nano Command
nano Command is a text Programming Command, used to display a small text editor.
Some examples of nano Command:
- Open and edit a file called “file.txt”:
nano file.txt
- Create and edit a new file called “newfile.txt”:
nano newfile.txt
- Open a file in read-only mode:
nano -m file.txt
117. netstat Command
netstat Command is a networking Command, used to displays network information and statistics.
Some examples of netstat Command:
- Display active connections and listening ports:
netstat -anp
The -a
option shows all connections and listening ports, the -n
option shows numerical addresses instead of trying to determine hostnames and -p
option shows the PID and name of the program to which each socket belongs.
- Display information only for a specific protocol:
netstat -tuln
The -t
option shows only TCP connections, -u
shows only UDP connections, -l
shows only listening sockets, and -n
shows numerical addresses instead of trying to determine hostnames.
- Display the routing table:
netstat -r
118. newgrp Command
newgrep Command is used to change to a new group.
Some examples of newgrp Command:
- Change the current group ID to the group “developers”:
newgrp developers
- Change the current group ID to the group “developers” and run a command with that group ID:
newgrp developers -
- Change the current group ID to the group “developers” and run a command with that group ID and login shell.
newgrp developers -l
119. nice Command
nice Command is a process Management to invoke a utility with an altered nice value.
Some examples of nice Command:
- Run a program called “myprogram” with a lower priority:
nice myprogram
- Run a program called “myprogram” with a lower priority and specify a priority value:
nice -n 10 myprogram
120. nl Command
nl Command is a text processing Command used for line numbering filter.
Some examples of nl Command:
- Number the lines of a file called “file.txt”:
nl file.txt
- Number the lines of a file called “file.txt” and start the line numbering with a specific number:
nl -v 5 file.txt
The -v
option is used to specify the starting line number.
- Number the lines of a file called “file.txt” and use a specific number separator:
nl -s ':' file.txt
121. nm Command
nm Command is a C Programming, used write the name list of an object file.
Some examples of nm Command:
- Display the symbol table of a binary file called “mybinary”:
nm mybinary
- Display the symbol table of a shared library called “libmylibrary.so”:
nm libmylibrary.so
122. nohup Command
nohup Command is a process Management Command, used to invoke a utility immune to hangups.
Some examples of nohup Command:
- Run a command in the background and ignore the HUP (hangup) signal:
nohup command &
- Run a command and redirect output to a file:
nohup command > output.file &
123. od Command
od Command is used to dump files in various formats.
Some examples of od Command:
- To display the contents of a file in octal format:
od -c file.txt
- To display the contents of a file in decimal format:
od -d file.txt
- To display the contents of a file in hexadecimal format:
od -x file.txt
124. parallel Command
parallel Command is a shell utility for executing jobs in parallel.
Some examples of parallel Command:
- To run multiple commands in parallel, simply list them one after the other, separated by
&
:
command1 &
command2 &
command3 &
- To run multiple commands in parallel and use the output of one command as input to another command:
command1 | parallel --pipe command2
125. passwd Command
passwd Command is a system Command used to set or change user password.
Some examples of passwd Command:
- To change the password for the current user:
passwd
- To change the password for a specific user:
sudo passwd username
- To change the password for a user, but not require the user to provide their current password:
sudo passwd -f username
126. paste Command
paste Command is a text processing, used to merge corresponding or subsequent lines of files.
Some examples of paste Command:
- To concatenate the contents of two files side by side:
paste file1.txt file2.txt
- To concatenate the contents of multiple files side by side:
paste file1.txt file2.txt file3.txt
127. patch Command
patch Command is a text processing utility to apply changes to files.
Some examples of patch Command:
- To apply a patch file to a file:
patch < patchfile.diff
- To apply a patch file to a file and create a backup copy of the original file:
patch -b < patchfile.diff
- To apply a patch file to a file and ignore whitespace differences:
patch -l < patchfile.diff
128. pathchk Command
pathchk Command is a filesystem utility used to check pathnames.
Some examples of pathchk Command:
- To check if a file named “example.txt” has a valid filename (no invalid characters, not too long), you can use the following command:
pathchk example.txt
- To check if a directory named “example_dir” has a valid pathname, you can use the following command:
pathchk -p example_dir
- To check if the current directory has a valid pathname, you can use the following command:
pathchk -p .
129. pax Command
pax Command is a portable archive interchange.
Some examples of pax Command:
- To archive a directory:
pax -w -f archive.pax /path/to/directory
- To extract files from an archive:
pax -r -f archive.pax
- To list the contents of an archive:
pax -f archive.pax -v
130. pgrep Command
pgrep Command is a process Management used to find processes with the given name using pattern matching.
Some examples of pgrep Command:
- To find the PID of a process by its name:
pgrep -x process_name
- To find all processes that belong to a specific user:
pgrep -u username
- To search for a process by its command line arguments:
pgrep -f 'arg1 arg2'
131. ping Command
ping Command is a network administration software utility used to test the reachability of a host on an Internet Protocol network.
Some examples of ping Command:
ping google.com
– sends ICMP packets to the host “google.com” and waits for repliesping -c 5 google.com
– sends 5 ICMP packets to “google.com” and then exitsping -i 3 google.com
– sends ICMP packets to “google.com” with a wait of 3 seconds between each packet
132. pkill Command
pkill Command is a process Management utility used to kill processes with the given name using pattern matching.
Some examples of pkill Command:
pkill firefox
– sends theSIGTERM
signal to all processes named “firefox”pkill -9 firefox
– sends theSIGKILL
signal (forcefully terminate) to all processes named “firefox”pkill -u user1
– sends theSIGTERM
signal to all processes running under the user “user1”
133. pr Command
pr (print) Command is a text processing Command used to print files.
Some examples of pr Command:
pr file.txt
– formats the contents of “file.txt” and sends the output to the terminalpr -d file.txt
– formats the contents of “file.txt” and adds page delimiters (form feed characters) to the outputpr -h "Title" -w 80 file.txt
– formats the contents of “file.txt” and adds a header with the title “Title” and sets the line width to 80 characters
134. print Command
print Command is used to print a file directly.
Some examples of print Command:
print $HOME
– prints the value of theHOME
environment variableprint "Hello, world!"
– prints the string “Hello, world!”print $(pwd)
– prints the output of thepwd
command
135. printf Command
printf Command is a shell programming utility, used to write formatted output.
Some examples of printf Command:
printf "Hello, %s!\n" world
– prints the string “Hello, world!”printf "%.2f\n" 3.141592
– prints the number “3.14” with two decimal placesprintf "The answer is %d\n" 42
– prints the string “The answer is 42”
136. prs Command
prs Command is a Source Code Control System (SCCS) Command, used to print an SCCS file.
Some examples of prs Command:
prs -e -r1.2 file.c
– lists the differences between version 1.2 and the current version of “file.c”prs -d -r1.1:1.5 file.c
– lists the differences between versions 1.1 and 1.5 of “file.c”
137. ps Command
ps Command is a process Management utility, used to report process status.
Some examples of ps Command:
ps
– displays a list of all processes running on the current terminalps -ef
– displays a list of all processes on the system in a “forest” format, showing the hierarchical relationship between processesps -u user1
– displays a list of all processes running under the user “user1”
138. pstree Command
pstree Command is a process Management utility, used to display a tree of processes.
Some examples of pstree Command:
pstree
– displays a tree of all processes running on the systempstree -p
– displays a tree of all processes running on the system and shows the process ID (PID) of each processpstree -u user1
– displays a tree of all processes running under the user “user1”
139. pwd Command
pwd Command is a filesystem utility used to print working directory or return working directory name.
Some examples of pwd Command:
pwd
This will print the current working directory.
You can also use pwd
command in conjunction with other commands like cd
to navigate the file system, for example:
cd /usr/local
pwd
140. qalter Command
qalter Command is a batch utility used to alter batch job
Some examples of qalter Command:
- To change the name of a job:
qalter -N new_job_name job_id
- To change the queue a job is running in:
qalter -q new_queue_name job_id
- To change the number of nodes or processors a job is requesting:
qalter -l nodes=4:ppn=8 job_id
141. qdel Command
qdel Command is a batch utility used to delete batch job.
Some examples of qdel Command:
- To delete a single job by specifying its job ID:
qdel 12345
- To delete multiple jobs by specifying their job IDs:
qdel 12345 12346 12347
142. qhold Command
qhold Command is a batch utility used to hold batch jobs.
Some examples of qhold Command:
- To hold a single job by specifying its job ID:
qhold 12345
- To hold multiple jobs by specifying their job IDs:
qhold 12345 12346 12347
143. qmove Command
qmove Command is a batch utility used to move batch job.
Some examples of qmove Command:
- To move a single job by specifying its job ID to another queue:
qmove new_queue_name 12345
- To move multiple jobs by specifying their job IDs to another queue:
qmove new_queue_name 12345 12346 12347
144. qmsg Command
qmsg Command is a batch utility used to send message across batch jobs.
Some examples of qmsg Command:
- To send a message to the user who submitted a single job by specifying its job ID:
qmsg -j 12345 "The job is running smoothly"
- To send a message to a specific user:
qmsg -u username "Your job is complete"
145. qrerun Command
qrerun Command is a batch utility used to rerun batch jobs
Some examples of qrerun Command:
- To rerun a single job by specifying its job ID:
qrerun 12345
- To rerun multiple jobs by specifying their job IDs:
qrerun 12345 12346 12347
- To rerun all of the jobs that belong to a specific user:
qrerun -u username
146. qrls Command
qrl Command is a batch utility used to release batch jobs
Some examples of qrls Command:
- To release a single job by specifying its job ID:
qrls 12345
- To release multiple jobs by specifying their job IDs:
qrls 12345 12346 12347
- To release all of the jobs that belong to a specific user:
qrls -u username
147. qselect Command
qselect Command is a batch utility used to select batch jobs
Some examples of qselect Command:
- To display all of the jobs that belong to a specific user:
qselect -u username
- To display all of the jobs that belong to the current user:
qselect -u $(whoami)
- To display all of the jobs that are currently running:
qselect -s R
148. qsig Command
qsig Command is a batch utility used to signal batch jobs
Some examples of qsig Command:
- To suspend a single job by specifying its job ID:
qsig -s suspend 12345
- To resume a single job by specifying its job ID:
qsig -s resume 12345
- To terminate a single job by specifying its job ID:
qsig -s term 12345
149. qstat Command
qstat Command is a batch utility used to show status of batch jobs
Some examples of qstat Command:
- To display information about a single job by specifying its job ID:
qstat 12345
- To display information about multiple jobs by specifying their job IDs:
qstat 12345 12346 12347
- To display information about all of the jobs that belong to a specific user:
qstat -u username
150. qsub Command
qsub Command is a batch utility used to submit batch jobs script.
Some examples of qsub Command:
- To submit a job script named “job.sh” to the batch system:
qsub job.sh
- To specify the number of processors and the amount of memory required by a job:
qsub -l nodes=1:ppn=8,mem=8gb job.sh
- To specify a walltime limit for a job:
qsub -l walltime=24:00:00 job.sh
151. read Command
read Command is a shell Programming, used to read a line from standard input.
Some examples of read Command:
read var
– This command reads input from the user and assigns it to the variablevar
. For example, if the user enters “hello”, the variablevar
would be set to “hello”.read -p "Enter your name: " name
– This command prompts the user to enter their name, and the input is assigned to the variablename
. The-p
option is used to display a prompt.read -a arr
– This command reads input and assigns it to an arrayarr
.
152. readlink Command
readlink Command is used to print resolved symbolic links or canonical file names.
Some examples of readlink Command:
readlink file.txt
– This command prints the value of the symbolic linkfile.txt
readlink -f file.txt
– This command prints the absolute path of the file or linkfile.txt
, resolving any intermediate symlinks. The-f
option is used to resolve the final target of the link.readlink -e file.txt
– This command prints the final target of the symbolic linkfile.txt
and returns true if the file or link exists else false. The-e
option is used to check if the link exists or not.
153. readonly Command
readlink Command is used to set the readonly attribute for variables
Some examples of readonly Command:
- To make a variable read-only:
$ var="hello"
$ readonly var
$ var="goodbye"
-bash: var: readonly variable
- To make a function read-only:
$ function myfunc { echo "hello"; }
$ readonly -f myfunc
$ myfunc() { echo "goodbye"; }
-bash: myfunc: cannot overwrite function
154. renice Command
renice Command is a process Management utility used to set nice values of running processes.
Some examples of renice Command:
- To change the priority of a process with a specific PID:
$ renice -n 10 -p 1234
- To change the priority of all processes running as a specific user:
$ renice -n 10 -u username
155. return Command
return Command is a shell Programming used to return from a function.
Some examples of return Command:
The following script defines a function myfunc
that takes a single argument and returns the square of that argument:
#!/bin/bash
myfunc() {
local arg=$1
local result=$((arg * arg))
return $result
}
myfunc 5
echo "The result is $?"
156. rm Command
rm Command is a filesystem utility, used to remove files or directories.
Some examples of rm Command:
- To remove a single file:
rm file.txt
- To remove multiple files at once:
rm file1.txt file2.txt file3.txt
- To remove a directory and all of its contents:
rm -r my_directory
157. rmdel Command
rmdel Command is a Source Code Control System (SCCS) utility, used to remove a delta from an SCCS file.
The rmdel
command in SCCS is used to remove a delta (a set of changes) from the SCCS file. This command can be used to remove a specific version of the file, or to remove a specific set of changes made to the file.
Here is an example of how to use the rmdel
command in SCCS:
Some examples of rmdel Command:
rmdel -r2 file.c
158. rmdir Command
rmdir (remove directory) Command is a filesystem utility, used to remove a directory from linux.
Some examples of rmdir Command:
- To remove an empty directory:
rmdir my_directory
- To remove multiple empty directories at once:
rmdir my_directory1 my_directory2 my_directory3
159. rsync Command
rsync Command is a fast and versatile command-line utility for synchronizing files and directories between two locations over a remote shell
Some examples of rsync Command:
- To copy a file from the local machine to a remote machine:
rsync file.txt [email protected]:/path/to/destination
- To copy a directory and its contents from the local machine to a remote machine:
rsync -avz my_directory [email protected]:/path/to/destination
- To copy a file from a remote machine to the local machine:
rsync [email protected]:file.txt /path/to/destination
160. sact Command
sact Command is a Source Code Control System (SCCS) utility, used to print current SCCS file-editing activity.
Some examples of sact Command:
sact File
161. sar Command
sar Command is a system administration utility, used for system activity report.
Some examples of sar Command:
- Display CPU usage statistics for the current day:
sar
- Display memory usage statistics for the current day:
sar -r
162. sccs Command
sccs Command is a Source Code Control Utility (SCCS), used for front end for the SCCS subsystem.
Some examples of sccs Command:
- Check out a file for editing:
sccs get file.c
- Check in a file after editing:
sccs delta file.c
- Show the history of a file:
sccs prs -l file.c
163. sed Command
sed Command is a text processing utility, is a stream editor.
Some examples of sed Command:
- Replace the first occurrence of a word in a file:
sed 's/word/replace/' file.txt
- Replace all occurrences of a word in a file:
sed 's/word/replace/g' file.txt
- Replace the nth occurrence of a word in a line:
sed 's/word/replace/3' file.txt
164. seq Command
seq Command is used to print a sequence of numbers.
Some examples of seq Command:
- To generate a sequence of numbers from 1 to 10, enter:
seq 1 10
- To generate a sequence of even numbers from 2 to 10, enter:
seq 2 2 10
- To generate a sequence of numbers from 10 to 1, with a decrement of 2, enter:
seq 10 -2 1
165. set Command
set Command is a used to set or unset options and positional parameters.
Some examples of set Command:
- To set a positional parameter, enter:
set -- arg1 arg2 arg3
This will set the positional parameters to “arg1”, “arg2”, and “arg3”.
- To display the current positional parameters, enter:
set
- To unset a positional parameter, enter:
set --
166. sh Command
sh Command is a shell programming utility, used to shell, the standard command language interpreter.
Some examples of sh Command:
- Run a shell script:
sh script.sh
- Run a command as a non-root user:
sh -c "command"
- Run a command with a specific shell:
sh -c "command" -s /bin/bash
167. shift Command
shift Command is a shell programming utility, used to shift positional parameters.
Some examples of shift Command:
- Shift the positional parameters to the left:
shift
- Shift the positional parameters to the left by a specific number:
shift 2
168. shopt Command
shopt Command is a shell programing utility, used to control optional shell behavior.
Some examples of shopt Command:
- Display the current value of an option:
shopt -p option_name
- Enable an option:
shopt -s option_name
- Disable an option:
shopt -u option_name
169. sleep Command
sleep Command is a shell programming utility, used to suspend execution for an interval.
Some examples of sleep Command:
- Sleep for 5 seconds:
sleep 5
- Sleep for 1 minute:
sleep 60
- Sleep for 2 hours and 30 minutes:
sleep 9000
170. sort Command
sort Command is a text processing utility used to sort, merge, or sequence check text files.
Some examples of sort Command:
- Sort a file alphabetically:
sort file.txt
- Sort a file in reverse order:
sort -r file.txt
- Sort a file numerically:
sort -n file.txt
171. split Command
split Command is used to split files into pieces.
Some examples of split Command:
- Split a file into smaller files of 1000 lines each:
split -l 1000 file.txt
- Split a file into smaller files of 100KB each:
split -b 100k file.txt
- Split a file into smaller files of 100 lines each and prefix the output files with ‘part’:
split -l 100 -d -a 3 file.txt part
172. ss Command
ss command is a linux utility used to displays information in similar fashion to netstat. Note that ss is a little crude compared to netstat.
Some examples of ss Command:
- Display all TCP connections:
ss -t
- Display all UDP connections:
ss -u
- Display all UNIX domain socket connections:
ss -x
173. stress Command
stress Command is a shell programming testing utility, which uses a square-root function to force the CPUs to work hard.
Some examples of stress Command:
- Stress the CPU for 60 seconds:
stress --cpu 4 --timeout 60s
- Stress the memory for 120 seconds:
stress --vm 2 --timeout 120s
- Stress the I/O for 30 seconds:
stress --io 2 --timeout 30s
174. strings Command
strings Command is a C programming utility, used to find printable strings in files.
Some examples of strings Command:
- Extract strings from a binary file:
strings binary_file
- Extract strings of at least 10 characters:
strings -n 10 binary_file
- Extract strings from a binary file and show the offset of each string:
strings -t x binary_file
175. strip Command
strip Command is a C programming utility, used to remove unnecessary information from executable files.
Some examples of strip Command:
- Strip all symbols from an object file:
strip file.o
- Strip only debugging symbols from an object file:
strip --strip-debug file.o
- Strip all symbols and debugging information from an executable:
strip --strip-all file
176. stty Command
stty Command is used to set the options for a terminal.
Some examples of stty Command:
- Display the current terminal settings:
stty -a
- Disable echo on the terminal:
stty -echo
- Enable echo on the terminal:
stty echo
177. suspend Command
suspend Command is a shell programming utility, used to suspend execution of the shell until it receives a continue signal.
Some examples of suspend Command:
- Suspend the current shell or terminal session:
suspend
- Resume the suspended shell or terminal session:
fg
178. tabs Command
tabs Command is a linux utility, used to create tabs in terminal.
Some examples of tabs Command:
You can use the following command to set the tab completion to use 8 columns:
echo "set tabsize 8" >> ~/.inputrc
This command will add the line “set tabsize 8” to the file .inputrc in your home directory. This will cause the tab completion to use 8 columns.
Another command tset
is used to set terminal modes, including setting the number of columns used for tab completion.
tset -Q -m 'tabs'
179. tail Command
tail Command is a text processing utility, used to copy the last part of a file.
Some examples of tail Command:
- Display the last 10 lines of a file:
tail /path/to/file.txt
- Display the last 20 lines of a file:
tail -n 20 /path/to/file.txt
- Display the last 100 bytes of a file:
tail -c 100 /path/to/file.txt
180. talk Command
talk Command is a linux utility, used to talk to another user.
Some examples of talk Command:
talk
181. tee Command
tee Command is a shell programming utility, used to duplicate standard input.
Some examples of tee Command:
- To write the output of the “ls” command to a file named “filelist.txt”, while also displaying the output on the screen, you can use the following command:
ls | tee filelist.txt
- To write the output of a command to multiple files at once, you can use the following command:
command | tee file1.txt file2.txt file3.txt
182. test Command
test Command is a Linux shell programming utility, used to evaluate expression, whether it is correct, before deployment.
Some examples of test Command:
- Check if a file exists:
test -e /path/to/file
- Check if a file is a directory:
test -d /path/to/directory
- Check if a file is a regular file (and not a directory or a link):
test -f /path/to/file
183. time Command
time Command is a Linux process management utility, used to time the execution of a simple command.
Some examples of time Command:
time ls -l
This command will display the contents of the current directory in a long format, and also display the time it took for the ls
command to run.
Another example:
time sleep 5
184. times Command
times Command is a process management utility, used to write process execution times.
Some examples of times Command:
times
This command will display the accumulated user and system CPU time for the current shell and its child processes.
The output of the command will be in the format:
user time system time children's user time children's system time
185. top Command
top Command is a process management utility, used to show real-time display of running processes.
Some examples of top Command:
top
186. touch Command
touch Command is a filesystem utility, used to create file and Change file access and modification times.
Some examples of touch Command:
touch file.txt
This command will create a new, empty file named “file.txt” in the current directory, or update the timestamp of an existing file with the same name.
Another example:
touch -a file.txt
This command will update the access timestamp of the file named “file.txt”, without modifying the file’s content.
187. tput Command
tput command allows shell scripts to do things like clear the screen, underline text, and center text no matter how wide the screen is.
Some examples of tput Command:
- Move the cursor to the x,y position on the screen:
tput cup x y
- Clear the screen:
tput clear
- Set the text color:
tput setaf color
(where color is a number representing the desired color)
188. tr Command
tr (translate) Command is a text processing utility, used to translate characters.
Some examples of tr Command:
- Translate all lowercase characters to uppercase:
tr a-z A-Z
- Delete all occurrences of the letter ‘a’:
tr -d a
- Squeeze repeating occurrences of the letter ‘a’ into one:
tr -s a
189. traceroute Command
traceroute command is used to determine the path between two connections.
Some examples of traceroute Command:
- Trace the route to a specific host:
traceroute example.com
- Use ICMP packets instead of UDP packets:
traceroute -I example.com
- Set the maximum number of hops:
traceroute -m 15 example.com
190. trap Command
trap Command is a process management utility, used to trap signals.
Some examples of trap Command:
- Specify a command to be executed when the script exits:
trap 'echo "Script exited"' EXIT
- Specify a command to be executed when the script receives a INT signal:
trap 'echo "Script interrupted"' INT
191. true Command
true Command is a shell programming utility, used to return true value.
Some examples of true Command:
true
command is mostly used in shell scripts as a placeholder command, or to ignore the exit status of a previous command.
Example:
#!/bin/bash
# This script will execute command1, even if command2 fails
command2 || true
command1
192. ts Command
ts command is to add timestamps to the beginning of each line of input.
Some examples of ts Command:
ts
command is mostly used in combination with other commands like tail
or grep
to timestamp log files.
Example:
#!/bin/bash
# This script will timestamp the output of the 'ls' command
ls -l | ts
193. tsort Command
tsort Command is a text processing utility, used to topological sort files.
Some examples of tsort Command:
Here are some examples of how to use the tsort
command:
- Sort a list of ordered pairs:
tsort input_file
- Sort a list of ordered pairs from standard input:
command1 | tsort
The input data must be in the form of ordered pairs, where each line represents an edge in a directed acyclic graph (DAG). The first element of the pair is the ‘to’ vertex, and the second element is the ‘from’ vertex.
Example:
#!/bin/bash
# This script will sort a list of ordered pairs
tsort input_file
194. tty Command
tty Command is used to return user’s terminal name.
Some examples of tty Command:
tty
command is mostly used in shell scripts to determine if the current shell is running in a terminal or if a command is being run in a non-interactive shell.
Example:
#!/bin/bash
# This script will print the file name of the terminal
tty
195. type Command
type Command is used to displays how a name would be interpreted if used as a command.
Some examples of type Command:
type
command is mostly used in shell scripts to determine how a command is executed and to find the location of a command.
Example:
#!/bin/bash
# This script will display information about a command
type ls
196. ulimit Command
ulimit Command is used to set or report file size limit.
Some examples of ulimit Command:
- To check the current open file limit for a user:
ulimit -n
- To increase the limit of open file to 4096:
ulimit -n 4096
- To check the current stack size limit:
ulimit -s
197. umask Command
umask Command is used to get or set the file mode creation mask.
Some examples of umask Command:
- To check the current umask value:
umask
- To set the umask value to 077, resulting in newly created files having permissions of 600 (rw——-) and newly created directories having permissions of 700 (rwx——):
umask 077
- To set the umask value to 002, resulting in newly created files having permissions of 664 (rw-rw-r–) and newly created directories having permissions of 775 (rwxrwxr-x):
umask 002
198. umount Command
unmount Command is used to unmount a filesystem.
Some examples of umount Command:
- To unmount a file system located at /mnt/data:
umount /mnt/data
- To unmount a file system by device name /dev/sdb1:
umount /dev/sdb1
- To force unmount a busy file system:
umount -l /mnt/data
199. unalias Command
unalias Command is used to remove aliases.
Some examples of unalias Command:
- o remove an alias named ‘ll’:
unalias ll
- To remove all defined aliases:
unalias -a
200. uname Command
uname Command is used to return system name.
Some examples of uname Command:
- To display the kernel version:
uname -r
- To display the hostname:
uname -n
- To display the processor architecture:
uname -m
201. uncompress Command
uncompress Command is used to uncompress or expand compressed data.
Some examples of uncompress Command:
- To decompress a file named “file.txt.Z”:
uncompress file.txt.Z
- To decompress multiple files at once:
uncompress file1.txt.Z file2.txt.Z file3.txt.Z
- To decompress a file and overwrite the original:
uncompress -f file.txt.Z
202. unexpand Command
unexpand Command is a text processing utility, used to convert spaces to tabs.
Some examples of unexpand Command:
- To convert all spaces at the beginning of each line in a file named “file.txt” to tabs:
unexpand file.txt
- To convert spaces to tabs with a tab stop of 8 characters:
unexpand -t 8 file.txt
- To convert spaces to tabs and also overwrite the original file:
unexpand -a file.txt
203. unget Command
unget Command is a Source Code Command System (SCCS) utility, used to undo a previous get of an SCCS file.
Some examples of unget Command:
an example of how the “unget” command can be used in a C program:
#include <stdio.h>
int main() {
char c;
printf("Enter a character: ");
c = getchar();
ungetc(c, stdin);
printf("You entered: ");
c = getchar();
printf("%c\n", c);
return 0;
}
204. uniq Command
uniq Command is a text processing utility, used to report or filter out repeated lines in a file.
Some examples of uniq Command:
- To remove duplicate lines from a file named “file.txt” and write the output to a new file named “output.txt”:
uniq file.txt output.txt
- To display only the duplicate lines in a file named “file.txt”:
uniq -d file.txt
- To display only the unique lines in a file named “file.txt”:
uniq -u file.txt
205. unlink Command
unlink Command is a filesystem utility used to call the unlink function.
Some examples of unlink Command:
- To remove a file named “file.txt”:
unlink file.txt
- To remove a file named “file.txt” and suppress error messages if the file doesn’t exist:
unlink -f file.txt
- To remove multiple files at once:
unlink file1.txt file2.txt file3.txt
206. unset Command
unset Command is used to unset values and attributes of variables and functions.
Some examples of unset Command:
- To remove a variable named “var”:
unset var
- To remove a function named “myfunc”:
unset -f myfunc
- To remove multiple variables at once:
unset var1 var2 var3
207. unzip Command
unzip Command is a Linux processing utility, used to unzip files on a terminal.
Some examples of unzip Command:
- To extract all files from a ZIP archive called “example.zip” in the current directory, you can use the following command:
unzip example.zip
- To extract files from a ZIP archive to a specific directory, use the -d option followed by the directory path:
unzip example.zip -d /path/to/directory
- To extract specific files from a ZIP archive, you can specify the file names after the archive name:
unzip example.zip file1.txt file2.txt
208. uptime Command
uptime Command is a Linux command that returns information about how long your system has been running together with the current time, with basic users information.
Some examples of uptime Command:
you can also use other command line utilities like awk
or cut
to extract specific information from the output of the uptime
command.
Example :
$ uptime
14:26:11 up 13 days, 4:44, 2 users, load average: 0.00, 0.01, 0.05
209. useradd Command
useradd Command is used to create new user accounts.
Some examples of useradd Command:
- To add a new user account called “john” with a default home directory, you can use the command
useradd john
- To specify a custom home directory for the new user, you can use the
-d
option, like this:useradd -d /home/john john
- To specify a specific user group for the new user, you can use the
-g
option, like this:useradd -g users john
210. userdel Command
userdel Command is used to delete create users.
Some examples of userdel Command:
It is important to note that if the user is currently logged in, the userdel command will not work. In that case, you can use pkill -KILL -u <username>
to forcefully log out the user.
Example :
$ userdel -r john
This command will delete the user account of “john” and also remove its home directory and files.
$ userdel -f john
211. uucp Command
uucp Command is a networking utility used for system-to-system copy.
Some examples of uucp Command:
- To copy a file called “file.txt” from the local system to a remote system called “remote”, you can use the command
uucp file.txt remote:/path/to/destination
- To copy a directory called “mydir” from the remote system “remote” to the local system, you can use the command
uucp remote:/path/to/mydir mydir
212. uudecode Command
uudecode Command is a networking utility used to decode a binary files.
Some examples of uudecode Command:
- To decode a file called “encoded-file.uu” and save the result as “decoded-file”, you can use the command
uudecode encoded-file.uu -o decoded-file
- To decode a file called “encoded-file.uu” and save the result in the same location with the same name but with the original file extension, you can use the command
uudecode encoded-file.uu
213. uuencode Command
uuencode Command is a networking utility used to encode a binary files.
Some examples of uuencode Command:
- To encode a file called “file.bin” and save the result as “encoded-file.uu”, you can use the command
uuencode file.bin encoded-file.uu
- To specify a different name for the encoded file, you can use the
-m
option, like this:uuencode file.bin encoded-file.uu -m file.bin
214. uustat Command
uustat Command is a networking utility, used to uucp status inquiry and job control.
Some examples of uustat Command:
- To display the status of all files in the UUCP queue, you can use the command
uustat
- To display the status of a specific file in the UUCP queue, you can specify the file name as an argument, like this:
uustat file.txt
215. uux Command
uux Command is a process management utility, used for remote command execution.
Some examples of uux Command:
- To execute the command “ls -l” on a remote system called “remote”, you can use the command
uux remote!ls -l
- To execute a command and redirect the output to a file, you can use the
>
operator, like this:uux remote!ls -l > remote-ls.txt
216. val Command
val Command is a Source Code Control System (SCCS) utility, used to validate SCCS files.
Some examples of val Command:
To determine if file zas.yesterblog.coder is an SCCS text file, enter:
val -ytext zas.yesterblog.coder
217. vi Command
vi Command is a text processing utility, used for screen-oriented (visual) display editor.
Some examples of vi Command:
- To open a file called “example.txt” in the current directory, use the command:
vi example.txt
- To open a new file called “newfile.txt” in the current directory, use the command:
vi newfile.txt
- To open a file called “example.txt” in a different directory, use the command:
vi /path/to/directory/example.txt
218. w Command
The “w” command in Linux is used to display information about the users currently logged into the system, as well as their processes. The output of the command includes the user’s login name, the tty or terminal they are using, their remote host (if applicable), their login time, the amount of time they have been idle, and the command they are currently running.
Here is an example of the output of the “w” command:
$ w
23:47:57 up 2 days, 2:55, 2 users, load average: 0.00, 0.01, 0.05
USER TTY FROM [email protected] IDLE JCPU PCPU WHAT
user1 tty1 21:01 2days 0.09s 0.09s -bash
user2 pts/0 192.168.1.100 22:35 23:47 0.00s 0.00s w
w Command is used to show who is logged on and what they are doing.
219. wait Command
wait Command is a process management utility, used to await process completion.
Some examples of wait Command:
Using the “wait” command to wait for a background process to complete:
$ command1 &
$ pid=$!
$ command2
$ wait $pid
220. wc Command
wc Command is a text processing utility, used for word, line, and byte or character count
Some examples of wc Command:
Here are some examples of using the “wc” command:
$ wc file.txt
This command will display the number of lines, words, and characters in the file “file.txt”. The output will be in the format: lines, words, characters, filename.
$ echo "hello world" | wc
This command will display the number of lines, words, and characters in the string “hello world”. The output will be in the format: lines, words, characters.
$ wc -l file.txt
221. what Command
what Command is a Source Code Control System (SCCS) utility, used to identify SCCS files
Some examples of what Command:
$ what /usr/bin/ls
This command will display the version of the “ls” command, which is located in the “/usr/bin” directory. The output will be in the format: filename, version.
222. whereis Command
whereis command in Linux is used to locate the binary, source, and manual page files for a command.
Some examples of whereis Command:
$ whereis ls
This command will display the location of the binary, source, and manual page files for the “ls” command. The output will be in the format: command: binary_location source_location manual_location
223. which Command
which command in linux is used to identify the location of executables.
Some examples of which Command:
which ls
– Displays the full path of the ‘ls’ commandwhich java
– Displays the full path of the ‘java’ commandwhich -a nano
– Displays all the paths of the ‘nano’ command, if multiple exist
224. who Command
who Command is a system administration utility, used to display who is on the system.
Some examples of who Command:
who
– Displays information about all users currently logged into the systemwho am i
– Displays information about the current userwho -u
– Displays information about all users, including those who have logged in and out
225. write Command
write Command is used to write to another user’s terminal.
Some examples of write Command:
write user1
– Sends a message to the user ‘user1’write user1 tty1
– Sends a message to the user ‘user1’ on terminal ‘tty1’write user1 < message.txt
– Sends the contents of the file ‘message.txt’ as a message to the user ‘user1’
226. xargs Command
xargs Command is a shell programming used to construct argument lists and invoke utility.
Some examples of xargs Command:
ls -l | xargs rm
– Lists all files in the current directory, then removes them usingrm
commandfind . -name "*.txt" | xargs grep "keyword"
– Search for the keyword in all text files in the current directory and subdirectoriescat file.txt | xargs -n1 command
– Take input from a file, split it into single line and pass it as an argument to a command.
227. yacc Command
yacc Command is a C programming utility, and stands for yet another compiler compiler. yacc command converts a context-free grammar specification into a set of tables for a simple automaton that executes an LALR(1) parsing algorithm.
Some examples of yacc Command:
- Create a file called “calc.y” and put the following grammar rules in it:
%{
#include <stdio.h>
%}
%token NUM
%left '+' '-'
%left '*' '/'
%right UMINUS
%%
expr : expr '+' expr
| expr '-' expr
| expr '*' expr
| expr '/' expr
| '-' expr %prec UMINUS
| NUM
;
%%
int yyerror(char *s) {
printf("error: %s\n", s);
}
int main(void) {
yyparse();
}
228. zcat Command
zcat Command is a text processing utility, used to expand and concatenate data.
Some examples of zcat Command:
zcat file.txt.gz
– Displays the contents of the gzip compressed file ‘file.txt.gz’zcat file1.txt.gz file2.txt.gz
– Displays the contents of multiple gzip compressed files ‘file1.txt.gz’ and ‘file2.txt.gz’zcat file.txt.gz | less
– Displays the contents of the gzip compressed file ‘file.txt.gz’ and pipes it through theless
command for better navigation.
229. zip Command
zip Command is used to create zip file from archives, to manage data more easily, and reduce data coruption.
Some examples of zip Command:
zip archive.zip file1.txt
– Compress the file ‘file1.txt’ into an archive called ‘archive.zip’zip -r archive.zip dir1
– Compress the entire directory ‘dir1’ and its contents into an archive called ‘archive.zip’zip -m archive.zip file1.txt
– Compress the file ‘file1.txt’ into an existing archive called ‘archive.zip’ and remove the original file
Linux Command Cheat Sheet (Categories)
Since Linux commands are so many, this cheat sheet, outlines the various types of Linux commands in their categories.
Batch Utilities Commands
Basic Batch Utilities Commands:
- qalter Command – Alter batch job
- qdel Command – Delete batch jobs
- qhold Command – Hold batch jobs
- qmove Command – Move batch jobs
- qmsg Command – Send message to batch jobs
- qrerun Command – Rerun batch jobs
- qrls Command – Release batch jobs
- qselect Command – Select batch jobs
- qsig Command – Signal batch jobs
- qstat Command – Show status of batch jobs
- qsub Command – Submit a script
C Programming Commands
Basic C Programming Commands:
- c99 Command – Compile standard C programs
- cflow Command – Generate a C-language flowgraph
- ctags Command – Create a tags file
- cxref Command – Generate a C-language program cross-reference table
- flex Command – Generate programs for lexical tasks
- fort77 Command – w:FORTRAN compiler
- lex Command – Generate programs for lexical tasks
- nm Command – Write the name list of an object file
- strings Command – Find printable strings in files
- strip Command – Remove unnecessary information from executable files
- yacc Command – Yet another compiler compiler
Filesystem Commands
Basic filesystem commands:
- basename Command – Return non-directory portion of a pathname
- cat Command – Concatenate and print files
- cd Command – Change the working directory
- chgrp Command – Change the file group ownership
- chmod Command – Change the file modes/attributes/permissions
- chown Command – Change the file ownership
- cksum Command – Write file checksums and sizes
- cmp Command – Compare two files
- compress Command – Compress data
- cp Command – Copy files
- dd Command – Convert and copy a file
- df Command – Report free disk space
- dirname Command – Return the directory portion of a pathname
- du Command – Estimate file space usage
- file Command – Determine file type
- find Command – Find files
- link Command – Call link function
- ln Command – Link files
- ls Command – List directory contents
- mkdir Command – Make directories
- mkfifo Command – Make FIFO special files
- mktemp Command – Create a temporary file or directory
- mount Command – Mount a file system
- mv Command – Move files
- pathchk Command – Check pathnames
- pwd Command – print working directory – Return working directory name
- rm Command – Remove files or directories
- rmdir Command – Remove directories
- touch Command – Create file and Change file access and modification times
- umount Command – Unmount a filesystem
- unlink Command – Call the unlink function
Input/Output information Command
Basic input/output information command:
- iostat Command – collect and show operating system storage input and output statistics
Internet Command
Basic internet command:
- ftp Command – Internet file transfer program
Network and Networking Commands
Basic networking commands:
- uucp Command – System-to-system copy
- uudecode Command – Decode a binary file
- uuencode Command – Encode a binary file
- uustat Command – uucp status inquiry and job control
- hostname Command – Show the system’s host name
- netstat Command – Displays network information and statistics
Process Management and Processes Commands
Basic process management commands:
- apt Command – For installing, updating, removing, and otherwise managing deb packages
- at Command – Execute commands at a later time
- batch Command – Schedule commands to be executed in a batch queue
- bg Command – Run jobs in the background
- fg Command – Run jobs in the foreground
- fuser Command – List process IDs of all processes that have one or more files open
- jobs Command – Display status of jobs in the current session
- kill Command – Terminate or signal processes
- nice Command – Invoke a utility with an altered nice value
- nohup Command – Invoke a utility immune to hangups
- pgrep Command – Find processes with the given name using pattern matching
- pkill Command – Kills processes with the given name using pattern matching
- ps Command – Report process status
- pstree Command – Display a tree of processes
- renice Command – Set nice values of running processes
- time Command – Time a simple command
- times Command – Write process times
- top Command – Real-time display of running processes
- trap Command – Trap signals
- uux Command – Remote command execution
- wait Command – Await process completion
- chroot Command – run a command or interactive shell using a specific directory as the root directory
Programming Command
Basic programming commands:
- make Command – Maintain, update, and regenerate groups of programs
Source Code Control System (SCCS) Command
Basic source code control system (sccs) commands:
- admin Command – Create and administer SCCS files
- delta Command – Make a delta (change) to an SCCS file
- get Command – Get a version of an SCCS file
- prs Command – Print an SCCS file
- rmdel Command – Remove a delta from an SCCS file
- sact Command – Print current SCCS file-editing activity
- sccs Command – Front end for the SCCS subsystem
- unget Command – Undo a previous get of an SCCS file
- val Command – Validate SCCS files
- what Command – Identify SCCS files
Shell programming
Basic shell programming commands:
- bash Command – The Bourne-again shell
- shopt Command – Control optional shell behavior
- break Command – Exit from for, while, or until loop
- continue Command – Continue from for, while, or until loop
- dot Command – Execute commands in the current environment
- echo Command – Write arguments to standard output
- eval Command – Construct command by concatenating arguments
- exec Command – Execute commands and open, close, or copy file descriptors
- exit Command – Cause the shell to exit
- false Command – Return false value
- logger Command – Log messages
- print Command – Print a file directly without using a Windows application that supports printing
- printf Command – Write formatted output
- sh Command – Shell, the standard command language interpreter
- shift Command – Shift positional parameters
- sleep Command – Suspend execution for an interval
- suspend Command – Suspend execution of the shell until it receives a continue signal
- tee Command – Duplicate standard input
- test Command – Evaluate expression
- true Command – Return true value
- command Command – Execute a simple command
- cut Command – Cut out selected fields of each line of a file
- expr Command – Evaluate arguments as an expression
- getopts Command – Parse utility options
- read Command – Read a line from standard input
- return Command – Return from a function
- xargs Command – Construct argument lists and invoke utility
System and System Administration Commands
Basic system and system administration commands:
- passwd Command – Set or change user password
- sar Command – System Activity Report
- who Command – Display who is on the system
Text Processing and Programming
Basic text processing and programming:
- awk Command – Pattern scanning and processing language
- diff Command – Compare two files
- ed Command – The standard text editor
- ex Command – Open text editor
- fold Command – Filter for folding lines
- gawk Command – Pattern scanning and processing language, GNU’s version of awk
- head Command – Copy the first part of files
- iconv Command – Codeset conversion
- less Command – Display files on a page-by-page basis
- more Command – Display files on a page-by-page basis
- paste Command – Merge corresponding or subsequent lines of files
- patch Command – Apply changes to files
- pr Command – Print files
- sed Command – Stream editor
- tail Command – Copy the last part of a file
- tr Command – Translate characters
- tsort Command – Topological sort
- vi Command – Screen-oriented (visual) display editor
- wc Command – Word, line, and byte or character count
- asa Command – Interpret carriage-control characters
- comm Command – Select or reject lines common to two files
- csplit Command – Split files based on context
- expand Command – Convert tabs to spaces
- join Command – Relational database operator
- lp Command – Send files to a printer
- nl Command – Line numbering filter
- sort Command – Sort, merge, or sequence check text files
- unexpand Command – Convert spaces to tabs
- uniq Command – Report or filter out repeated lines in a file
- zcat Command – Expand and concatenate data
- nano Command – Small text editor
Miscellenous (Misc) Commands
Miscellenous (misc) commands:
- alias Command – Define or display aliases
- ar Command – Create and maintain library archives
- bc Command – Arbitrary-precision arithmetic language
- cal Command – Print a calendar
- crontab Command – Schedule periodic background work
- date Command – Write the date and time
- env Command – List environment variables or invoke a command in a modified environment
- export Command – Set the export attribute for variables
- fc Command – Process the command history list
- fortune Command – Displays a random quotation
- gencat Command – Generate a formatted message catalog
- getconf Command – Get configuration values
- grep Command – Search text for a pattern
- groups Command – List groups a user belongs to
- hash Command – Remember or report utility locations
- id Command – Return user identity
- ipcrm Command – Remove a message queue, semaphore set, or shared memory segment identifier
- ipcs Command – Report interprocess communication facilities status
- locale Command – Get locale-specific information
- localedef Command – Define locale environment
- login Command – Begin sessions on a system
- logname Command – Return the user’s login name
- logout Command – End sessions on a system
- m4 Command – Macro processor
- mailx Command – Process messages
- man Command – Display system documentation
- mesg Command – Permit or deny messages
- newgrp Command – Change to a new group
- od Command – Dump files in various formats
- pax Command – Portable archive interchange
- readonly Command – Set the readonly attribute for variables
- seq Command – Print a sequence of numbers
- set Command – Set or unset options and positional parameters
- split Command – Split files into pieces
- stty Command – Set the options for a terminal
- tabs Command – Set terminal tabs
- talk Command – Talk to another user
- tput Command – Change terminal characteristics
- tty Command – Return user’s terminal name
- type Command – Displays how a name would be interpreted if used as a command
- ulimit Command – Set or report file size limit
- umask Command – Get or set the file mode creation mask
- unalias Command – Remove alias definitions
- uname Command – Return system name
- uncompress Command – Expand compressed data
- unset Command – Unset values and attributes of variables and functions
- write Command – Write to another user’s terminal
Other Commands
Other commands:
- datamash Command – performs basic numeric, textual and statistical operations on input textual data files
- mtail Command – extract metrics from application logs
- parallel Command – execute jobs in parallel (shell utility)
- rsync Command – synchronizing files and directories between two locations over a remote shell (command-line utility)
- stress Command – square-root function to force the CPUs to work hard
- readlink Command – print resolved symbolic links or canonical file names
- ts Command – adds a timestamp to the beginning of each line of input
- uptime Command – returns information about how long your system has been running together with the current time
- history Command – list all commands history used on a system
- zip Command – compress file
- unzip Command – uncompress file
- hostname Command – display the IP address of the remote machine
- useradd Command – add user
- userdel Command – delete user
- clear Command – clear all inputed commands, as if you just logged into terminal
- dir Command – computer file and directory listing
- groupadd Command – create new group account
- groupdel Command – delete existing group account
- last Command – show last logged-in user
- locate Command – search for directory
- ping Command – test ip address accesibility
- ss Command – dump socket statistics and displays information
- traceroute Command – determine the path between two connections
- whereis Command – locate the binary, source, and manual page files for a command
- which Command – identify the location of executables
- htop Command – monitor server’s processes in real time
- dc Command –
200+ Basic Linux Commands listed (alphabetically) with examples:
- admin Command
- alias Command
- apt Command
- ar Command
- asa Command
- at Command
- awk Command
- basename Command
- bash Command
- batch Command
- bc Command
- bg Command
- break Command
- c99 Command
- cal Command
- cat Command
- cd Command
- cflow Command
- chgrp Command
- chmod Command
- chown Command
- chroot Command
- cksum Command
- clear Command
- cmp Command
- comm Command
- command Command
- compress Command
- continue Command
- cp Command
- crontab Command
- csplit Command
- ctags Command
- cut Command
- cxref Command
- datamash Command
- date Command
- dc Command
- dd Command
- delta Command
- df Command
- diff Command
- dir Command
- dirname Command
- dot Command
- du Command
- echo Command
- ed Command
- env Command
- eval Command
- ex Command
- exec Command
- exit Command
- expand Command
- export Command
- expr Command
- false Command
- fc Command
- fg Command
- file Command
- find Command
- flex Command
- fold Command
- fort77 Command
- fortune Command
- ftp Command
- fuser Command
- gawk Command
- gencat Command
- get Command
- getconf Command
- getopts Command
- grep Command
- groupadd Command
- groupdel Command
- groups Command
- hash Command
- head Command
- history Command
- hostname Command
- htop Command
- iconv Command
- id Command
- iostat Command
- ipcrm Command
- ipcs Command
- jobs Command
- join Command
- kill Command
- last Command
- less Command
- lex Command
- link Command
- ln Command
- locale Command
- localedef Command
- locate Command
- logger Command
- login Command
- logname Command
- logout Command
- lp Command
- ls Command
- m4 Command
- mailx Command
- make Command
- man Command
- mesg Command
- mkdir Command
- mkfifo Command
- mktemp Command
- more Command
- mount Command
- mtail Command
- mv Command
- nano Command
- netstat Command
- newgrp Command
- nice Command
- nl Command
- nm Command
- nohup Command
- od Command
- parallel Command
- passwd Command
- paste Command
- patch Command
- pathchk Command
- pax Command
- pgrep Command
- ping Command
- pkill Command
- pr Command
- print Command
- printf Command
- prs Command
- ps Command
- pstree Command
- pwd Command
- qalter Command
- qdel Command
- qhold Command
- qmove Command
- qmsg Command
- qrerun Command
- qrls Command
- qselect Command
- qsig Command
- qstat Command
- qsub Command
- read Command
- readlink Command
- readonly Command
- renice Command
- return Command
- rm Command
- rmdel Command
- rmdir Command
- rsync Command
- sact Command
- sar Command
- sccs Command
- sed Command
- seq Command
- set Command
- sh Command
- shift Command
- shopt Command
- sleep Command
- sort Command
- split Command
- ss Command
- stress Command
- strings Command
- strip Command
- stty Command
- suspend Command
- tabs Command
- tail Command
- talk Command
- tee Command
- test Command
- time Command
- times Command
- top Command
- touch Command
- tput Command
- tr Command
- traceroute Command
- trap Command
- true Command
- ts Command
- tsort Command
- tty Command
- type Command
- ulimit Command
- umask Command
- umount Command
- unalias Command
- uname Command
- uncompress Command
- unexpand Command
- unget Command
- uniq Command
- unlink Command
- unset Command
- unzip Command
- uptime Command
- useradd Command
- userdel Command
- uucp Command
- uudecode Command
- uuencode Command
- uustat Command
- uux Command
- val Command
- vi Command
- w Command
- wait Command
- wc Command
- what Command
- whereis Command
- which Command
- who Command
- write Command
- xargs Command
- yacc Command
- zcat Command
- zip Command
References
- admin Command
- alias Command
- apt Command
- ar Command
- asa Command
- at Command
- awk Command
- basename Command
- bash Command
- batch Command
- bc Command
- bg Command
- break Command
- c99 Command
- cal Command
- cat Command
- cd Command
- cflow Command
- chgrp Command
- chmod Command
- chown Command
- chroot Command
- cksum Command
- clear Command
- cmp Command
- comm Command
- command Command
- compress Command
- continue Command
- cp Command
- crontab Command
- csplit Command
- ctags Command
- cut Command
- cxref Command
- datamash Command
- date Command
- dc Command
- dd Command
- delta Command
- df Command
- diff Command
- dir Command
- dirname Command
- dot Command
- du Command
- echo Command
- ed Command
- env Command
- eval Command
- ex Command
- exec Command
- exit Command
- expand Command
- export Command
- expr Command
- false Command
- fc Command
- fg Command
- file Command
- find Command
- flex Command
- fold Command
- fort77 Command
- fortune Command
- ftp Command
- fuser Command
- gawk Command
- gencat Command
- get Command
- getconf Command
- getopts Command
- grep Command
- groupadd Command
- groupdel Command
- groups Command
- hash Command
- head Command
- history Command
- hostname Command
- htop Command
- iconv Command
- id Command
- iostat Command
- ipcrm Command
- ipcs Command
- jobs Command
- join Command
- kill Command
- last Command
- less Command
- lex Command
- link Command
- ln Command
- locale Command
- localedef Command
- locate Command
- logger Command
- login Command
- logname Command
- logout Command
- lp Command
- ls Command
- m4 Command
- mailx Command
- make Command
- man Command
- mesg Command
- mkdir Command
- mkfifo Command
- mktemp Command
- more Command
- mount Command
- mtail Command
- mv Command
- nano Command
- netstat Command
- newgrp Command
- nice Command
- nl Command
- nm Command
- nohup Command
- od Command
- parallel Command
- passwd Command
- paste Command
- patch Command
- pathchk Command
- pax Command
- pgrep Command
- ping Command
- pkill Command
- pr Command
- print Command
- printf Command
- prs Command
- ps Command
- pstree Command
- pwd Command
- qalter Command
- qdel Command
- qhold Command
- qmove Command
- qmsg Command
- qrerun Command
- qrls Command
- qselect Command
- qsig Command
- qstat Command
- qsub Command
- read Command
- readlink Command
- readonly Command
- renice Command
- return Command
- rm Command
- rmdel Command
- rmdir Command
- rsync Command
- sact Command
- sar Command
- sccs Command
- sed Command
- seq Command
- set Command
- sh Command
- shift Command
- shopt Command
- sleep Command
- sort Command
- split Command
- ss Command
- stress Command
- strings Command
- strip Command
- stty Command
- suspend Command
- tabs Command
- tail Command
- talk Command
- tee Command
- test Command
- time Command
- times Command
- top Command
- touch Command
- tput Command
- tr Command
- traceroute Command
- trap Command
- true Command
- ts Command
- tsort Command
- tty Command
- type Command
- ulimit Command
- umask Command
- umount Command
- unalias Command
- uname Command
- uncompress Command
- unexpand Command
- unget Command
- uniq Command
- unlink Command
- unset Command
- unzip Command
- uptime Command
- useradd Command
- userdel Command
- uucp Command
- uudecode Command
- uuencode Command
- uustat Command
- uux Command
- val Command
- vi Command
- w Command
- wait Command
- wc Command
- what Command
- whereis Command
- which Command
- who Command
- write Command
- xargs Command
- yacc Command
- zcat Command
- zip Command
See Also:
0 Comments