User Tools

Site Tools


system-and-terminal

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
system-and-terminal [2019/10/08 00:15]
Miroslav Bernát
system-and-terminal [2020/04/20 20:25] (current)
Miroslav Bernát
Line 5: Line 5:
 | **lsb_release** | prints LSB (Linux Standard Base) version, **-i** linux distribution,​ **-r** version of the linux distribution,​ **-d** linux distribution name and version, **-c** codename of the distribution version, **-s** short output (without header), **-a** all information\\ ''​$ lsb_release -si''​\\ (prints linux distribution name) | | **lsb_release** | prints LSB (Linux Standard Base) version, **-i** linux distribution,​ **-r** version of the linux distribution,​ **-d** linux distribution name and version, **-c** codename of the distribution version, **-s** short output (without header), **-a** all information\\ ''​$ lsb_release -si''​\\ (prints linux distribution name) |
 | **cat /​etc/​*release** / **lsb_release -d** | prints linux distribution name and version | | **cat /​etc/​*release** / **lsb_release -d** | prints linux distribution name and version |
-| **dmidecode** | displays the system’s hardware components and BIOS information,​ **-s** <​keyword>​ information only about a specified item from the list of available keywords\\ ''#​ dmidecode -s system-uuid''​\\ (prints the system ID)\\ ''#​ dmidecode -s system-product-name | egrep -i '​virtual|vm|bochs'''​\\ (prints information whether the system is a virtual server) |+| **dmidecode** | displays the system’s hardware components and BIOS information,​ **-s** <​keyword>​ information only about a specified item from the list of available keywords\\ ''#​ dmidecode -s system-product-name''​\\ (prints the machine type (first 4 characters) and model)\\ ''#​ dmidecode -s system-serial-number''​\\ (prints the system serial number)\\ ''#​ dmidecode -s system-uuid''​\\ (prints the system ID)\\ ''#​ dmidecode -s system-product-name | egrep -i '​virtual|vm|bochs'''​\\ (prints information whether the system is a virtual server) |
 | **lscpu** | displays information about the CPU | | **lscpu** | displays information about the CPU |
 | **cat /​proc/​cpuinfo** | displays detailed information about the particular CPU cores | | **cat /​proc/​cpuinfo** | displays detailed information about the particular CPU cores |
Line 69: Line 69:
 | **export** (<​variable(=value)>​) | exports a local variable in order to be valid also for subshells within the same session (permanent local variables are defined and exported in //​~/​.bash_profile//,​ global variables in ///​etc/​profile//​);​ without an argument all exported variables are printed, **-n** <​variable>​ unexports a variable\\ ''​$ export x''​ / ''​export x=y''​ | | **export** (<​variable(=value)>​) | exports a local variable in order to be valid also for subshells within the same session (permanent local variables are defined and exported in //​~/​.bash_profile//,​ global variables in ///​etc/​profile//​);​ without an argument all exported variables are printed, **-n** <​variable>​ unexports a variable\\ ''​$ export x''​ / ''​export x=y''​ |
 | **echo** (<​text>​ / $<​variable>​) | prints a blank line or a specified text or value of the variable, **-n** suppresses a new line output after the last argument (useful in scripts)\\ ''​$ echo "End of file" >> ~/​file.txt''​\\ ''​$ echo -n 'Enter the required action: '''​ | | **echo** (<​text>​ / $<​variable>​) | prints a blank line or a specified text or value of the variable, **-n** suppresses a new line output after the last argument (useful in scripts)\\ ''​$ echo "End of file" >> ~/​file.txt''​\\ ''​$ echo -n 'Enter the required action: '''​ |
-| **printf** <​format>​ (<​argument>​) | prints a formatted string; format specification e.g: **%s** string, **%d** decadic integer, **%%** %, **\n** new line, **\t** tabulator\\ ''​$ printf "​Hello,​ I am %s.\n" $LOGNAME''​\\ ''​$ printf "​%s\t%s\t%s\n"​ Buy Sale Profit''​\\ ''​$ for i in $(seq 1 10); do printf "​%03d\n"​ "​$i";​ done''​\\ (prints numbers 1–10 in a 3-digit format starting with zero)\\ ''​$ printf "#​%.0s"​ {1..10}''​\\ (prints a specified string 10 times) |+| **printf** <​format>​ (<​argument>​) | prints a formatted string; format specification e.g: **%s** string, **%d** decadic integer, **%****%** %, **\n** new line, **\t** tabulator\\ ''​$ printf "​Hello,​ I am %s.\n" $LOGNAME''​\\ ''​$ printf "​%s\t%s\t%s\n"​ Buy Sale Profit''​\\ ''​$ for i in $(seq 1 10); do printf "​%03d\n"​ "​$i";​ done''​\\ (prints numbers 1–10 in a 3-digit format starting with zero)\\ ''​$ printf "#​%.0s"​ {1..10}''​\\ (prints a specified string 10 times) |
 | **eval** <​argument>​ | concatenates arguments and executes them as a shell command\\ ''​$ user=david; eval cd ~$user''​ | | **eval** <​argument>​ | concatenates arguments and executes them as a shell command\\ ''​$ user=david; eval cd ~$user''​ |
 | **xargs** (<​command>​) | reads and divides a large amount of arguments from STDIN into smaller parts in order to be acceptable for the following command that is to be executed (usually it is not possible to assign an unlimited number of arguments to a command), **-0** arguments are terminated by a null character instead of by whitespace and the quotes and backslash have no special meaning (this option must also be supported by the command providing the input for "​xargs"​),​ **-t** prints the command line on STDERR before executing it\\ ''#​ find . -name core -print0 | xargs -0 -t rm''​\\ ''#​ find / -user tom | xargs -t rm -Rf''​\\ ''​$ find . -type d | xargs chmod 750''​\\ ''​$ find . -atime -1 -type f | xargs ls -lutr | tail -1''​ | | **xargs** (<​command>​) | reads and divides a large amount of arguments from STDIN into smaller parts in order to be acceptable for the following command that is to be executed (usually it is not possible to assign an unlimited number of arguments to a command), **-0** arguments are terminated by a null character instead of by whitespace and the quotes and backslash have no special meaning (this option must also be supported by the command providing the input for "​xargs"​),​ **-t** prints the command line on STDERR before executing it\\ ''#​ find . -name core -print0 | xargs -0 -t rm''​\\ ''#​ find / -user tom | xargs -t rm -Rf''​\\ ''​$ find . -type d | xargs chmod 750''​\\ ''​$ find . -atime -1 -type f | xargs ls -lutr | tail -1''​ |
 | **expr** <​expression>​ | evaluates mathematical and other expressions;​ individual arguments are separated by spaces and special characters must be suppressed against the shell expansion\\ ''​$ expr 7 + 3''​\\ ''​$ expr "​("​ 6 - 3 "​)"​ "​*"​ 10''​\\ ''​$ expr length ABCD''​ | | **expr** <​expression>​ | evaluates mathematical and other expressions;​ individual arguments are separated by spaces and special characters must be suppressed against the shell expansion\\ ''​$ expr 7 + 3''​\\ ''​$ expr "​("​ 6 - 3 "​)"​ "​*"​ 10''​\\ ''​$ expr length ABCD''​ |
 | **bc** (<​file>​) | evaluates mathematical and other expressions from a specified file; without an argument it works interactively | | **bc** (<​file>​) | evaluates mathematical and other expressions from a specified file; without an argument it works interactively |
-| **seq** <​specification>​ | prints a sequence of numbers (one on each line) defined by an upper and possibly lower limit or an increment, **-f** <​format>​ in a specified format, **-s** <​string>​ uses a string to separate the numbers, **-w** equalizes width by padding with leading zeroes in front of a single digit\\ ''​$ seq 2 5''​\\ (a lower and upper limit defined)\\ ''​$ seq 1 .2 3''​\\ (a lower and upper limit defined including an increment)\\ ''​$ seq -w 15''​\\ (digits 01–15)\\ ''​$ seq -s ':'​ 10''​\\ (digits 1–10 separated by „:“\\ ''​$ seq -f '​***%g***'​ 3''​\\ (digits 1–3 between three stars)\\ ''​$ for i in $(seq 1 100); do expr $i "​*"​ $i; done''​\\ (prints the square of numbers 1–100, each on a separate line) |+| **seq** <​specification>​ | prints a sequence of numbers (one on each line) defined by an upper and possibly lower limit or an increment, **-f** <​format>​ in a specified format, **-s** <​string>​ uses a string to separate the numbers, **-w** equalizes width by padding with leading zeroes in front of a single digit\\ ''​$ seq 2 5''​\\ (a lower and upper limit defined)\\ ''​$ seq 1 .2 3''​\\ (a lower and upper limit defined including an increment)\\ ''​$ seq -w 15''​\\ (digits 01–15)\\ ''​$ seq -s ':'​ 10''​\\ (digits 1–10 separated by „:“\\ ''​$ seq -f %%'​***%g***'​%% 3''​\\ (digits 1–3 between three stars)\\ ''​$ for i in $(seq 1 100); do expr $i "​*"​ $i; done''​\\ (prints the square of numbers 1–100, each on a separate line) |
 | **yes** (<​string>​) | repeats printing „y“ or a specified string (one on each line) | | **yes** (<​string>​) | repeats printing „y“ or a specified string (one on each line) |
 | **time** <​command>​ | measures the time of a command execution\\ ''​$ time wget google.com''​ | | **time** <​command>​ | measures the time of a command execution\\ ''​$ time wget google.com''​ |
 | **alias** (<​custom_command>​=<​command>​) | defines an alias for the specified command (permanent setup in //​~/​.bashrc//​);​ without an argument all current aliases are printed\\ ''​$ alias nopaste='​curl -F file=@- nopaste.com/​a'''​ | | **alias** (<​custom_command>​=<​command>​) | defines an alias for the specified command (permanent setup in //​~/​.bashrc//​);​ without an argument all current aliases are printed\\ ''​$ alias nopaste='​curl -F file=@- nopaste.com/​a'''​ |
 | **unalias** <​your_own_command>​ | cancels an alias, **-a** removes all aliases | | **unalias** <​your_own_command>​ | cancels an alias, **-a** removes all aliases |
-| **script** <​file>​ | saves everything that is displayed after executing the program on STDOUT into the specified file, **-a** appends the output into the existing file, **-c** <​command>​ saves the specified command`s output only, **ctrl**+**d** exits the program | +| **script** <​file>​ | saves everything that is displayed after executing the program on STDOUT into the specified file, **-a** appends the output into the existing file, **-c** <​command>​ saves the specified command`s output only, **Ctrl**+**d** exits the program | 
-| **history** <n> | prints history of last //n// commands, **-c** ​removes ​history |+| **history** ​(<n>| prints history of last //n// commands ​(last 1000 commands by default), **-c** ​clears the history, **-d** <n> clears the history entry at the specified position (line) ​|
 | **fc** (<n> / <n m>) | edits last (specified) command(s) by default editor, **-e** <​editor>​ selects an editor, **-l** prints a numbered list of last executed (specified) commands, **-r** reverses the order of the commands, **-s** executes the last (specified) command from history\\ ''​$ fc -l -20 | grep cat''​\\ (prints last 20 commands containing „cat“)\\ ''​$ fc -l 210 250''​\\ (prints a list of commands in the specified range)\\ ''​$ fc -s''​ / ''​fc !!''​\\ (executes the previous command)\\ ''​$ fc -s 560''​ / ''​fc !560''​\\ (executes a specified command) | | **fc** (<n> / <n m>) | edits last (specified) command(s) by default editor, **-e** <​editor>​ selects an editor, **-l** prints a numbered list of last executed (specified) commands, **-r** reverses the order of the commands, **-s** executes the last (specified) command from history\\ ''​$ fc -l -20 | grep cat''​\\ (prints last 20 commands containing „cat“)\\ ''​$ fc -l 210 250''​\\ (prints a list of commands in the specified range)\\ ''​$ fc -s''​ / ''​fc !!''​\\ (executes the previous command)\\ ''​$ fc -s 560''​ / ''​fc !560''​\\ (executes a specified command) |
 | **clear** | clears the terminal screen | | **clear** | clears the terminal screen |
 | **reset** | clears the terminal screen and sets its default values | | **reset** | clears the terminal screen and sets its default values |
-| **exit** / **ctrl**+**d** | exits a shell (logs off a user) |+| **exit** / **Ctrl**+**d** | exits a shell (logs off a user) |
 | **logout** | exits a login shell | | **logout** | exits a login shell |
 | **setenforce** <​mode>​ | sets a SELinux mode if it is enabled (**0** = permissive – the security policy is not applied, only possible warning messages are being logged into ///​var/​log/​messages//,​ **1** = enforcing – the security policy defining files' access control is used; permanent setup in ///​etc/​selinux/​config//​) | | **setenforce** <​mode>​ | sets a SELinux mode if it is enabled (**0** = permissive – the security policy is not applied, only possible warning messages are being logged into ///​var/​log/​messages//,​ **1** = enforcing – the security policy defining files' access control is used; permanent setup in ///​etc/​selinux/​config//​) |
Line 95: Line 95:
 | **getsebool** (<​boolean>​) | prints a current SELinux boolean state, **-a** prints all booleans and their states | | **getsebool** (<​boolean>​) | prints a current SELinux boolean state, **-a** prints all booleans and their states |
 | **sealert** | displays useful information to help with SELinux troubleshooting,​ **-a** <​file>​ prints all incidents in the file, **-l** <ID> prints information about a specified incident\\ ''#​ sealert -a /​var/​log/​audit/​audit.log''​ | | **sealert** | displays useful information to help with SELinux troubleshooting,​ **-a** <​file>​ prints all incidents in the file, **-l** <ID> prints information about a specified incident\\ ''#​ sealert -a /​var/​log/​audit/​audit.log''​ |
 +\\
 +^ Bash Keyboard Shortcuts ^ ^
 +| **Commands / File Names Completions:​** | |
 +| **Tab** | allows to quickly complete commands or file names after they have been typed enough at the prompt to make them unique; if the characters typed are not unique, pressing the Tab key twice displays all available commands or file names that begin with the characters already typed |
 +| **Command History:** | |
 +| **Ctrl**+**p** / **Up Arrow** | prints the previous command in the history |
 +| **Ctrl**+**n** / **Down Arrow** | prints the next command in the history |
 +| **Ctrl**+**r** | searches the command history for a pattern typed (press it again for the next search) |
 +| **Ctrl**+**o** | executes the command found with "​Ctrl+r"​ |
 +| **Ctrl**+**g** | exits the command history search |
 +| **Process Management:​** | |
 +| **Ctrl**+**c** | terminates a running process in the foreground |
 +| **Ctrl**+**d** | terminates a running process that reads data from STDIN / exits the current shell |
 +| **Ctrl**+**z** | suspends a running job in the foreground |
 +| **Ctrl**+**s** | suspends all output to the screen (useful when running a command with a long verbose output, but it is not necessary to terminate the process) |
 +| **Ctrl**+**q** | resumes the output to the screen after stopping it with "​Ctrl+s"​ |
 +| **Moving the Cursor:** | |
 +| **Ctrl**+**b** / **Left Arrow** | moves the cursor one character to the left |
 +| **Ctrl**+**f** / **Right Arrow** | moves the cursor one character to the right |
 +| **Alt**+**b** | moves the cursor one word to the left |
 +| **Alt**+**f** | moves the cursor one word to the right |
 +| **Ctrl**+**a** | moves the cursor to the beginning of the command line |
 +| **Ctrl**+**e** | moves the cursor to the end of the command line |
 +| **Editing the Characters:​** | |
 +| **Ctrl**+**d** / **Delete** | clears the character under the cursor |
 +| **Ctrl**+**h** / **Backspace** | clears the character before the cursor |
 +| **Ctrl**+**u** | clears all characters before the cursor, adding them to the clipboard |
 +| **Ctrl**+**k** | clears all characters after the cursor, adding them to the clipboard |
 +| **Ctrl**+**l** | clears the whole screen |
 +| **Ctrl**+**y** | pastes the last characters added to the clipboard |
 +| **Alt**/​**Esc**+**.** | inserts the last word of the previous command at the cursor'​s current position |
 +| **Alt**+**u** | converts the characters from the cursor to the end of the current word to upper case |
 +| **Alt**+**l** | converts the characters from the cursor to the end of the current word to lower case |
 +| **Ctrl**+**_** | undoes the change before the last key press |