Commands
| Command | Description | ||
|---|---|---|---|
| File Commands | Basic File Operations | ls | list |
| cp | copy | ||
| mv | move | ||
| Directory Operations | cd | change directory | |
| pwd | print working directory | ||
Essential Concepts
| command | useful flags |
|---|---|
| ls | -lG |
| df | |
| top | -d1 |
| lpr | |
| last | |
| curl | -o url file |
| whois | |
| clear | |
| wc | -f file |
| cd | ~fred |
| pwd | |
| printenv | |
| type | wc cd ll |
| which | |
| alias | |
| sort | |
| date | |
| set | history |
| tmux | |
| sleep | |
| man | |
| info | |
| exit | |
| less |
Shell Job Control
| jobs | & |
|---|---|
| ^Z | suspend |
| fg | %1 |
| bg | |
| disown |
File Commands
Basic File Operations
| command | description |
|---|---|
| ls | list files in a directory |
| cp | copy a file |
| mv | move (rename) a file |
| rm | remove (delete) a file |
| ln | create links (alternative names) to a file |
Directory Operations
| command | description |
|---|---|
| cd | change your current directory |
| pwd | print the name of your current directory |
| basename | print the final part of a file path, usually the filename |
| dirname | print a file path without its final part |
| mkdir | create (make) a directory |
| rmdir | delete (remove) an empty directory |
| rm -r | delete a nonempty directory and its contents |
Viewing Files
| command | description |
|---|---|
| cat | view files in their entirety |
| less | view text files one page at a time |
| nl | view text files with their lines numbered |
| head | view the first lines of a text file |
| tail | view the last lines of a text file |
| strings | display text that’s embedded in a binary file |
| od | view data in octal (base 8) or other formats |
Creating and Editing Files
| command | description |
|---|---|
| nano | a simple text editor found in virtually all Linux distros |
| emacs | a powerful text editor from the Free Software Foundation |
| vim | a powerful text editor based on Unix vi |
Properties of Files
| command | description |
|---|---|
| stat | display attributes of files and directories |
| wc | count bytes, words, and lines in a file |
| du | measure disk usage of files and directories |
| file | identify (guess) the type of a file |
| mimetype | identify (guess) the MIME type of a file |
| touch | change timestamps of files and directories |
| chown | change owner of files and directories |
| chgrp | change group ownership of files and directories |
| chmod | change protection mode of files and directories |
| umask | set a default mode for new files and directories |
| lsattr | list extended attributes of files and directories |
| chattr | change extended attributes of files and directiories |
Locating Files
| command | description |
|---|---|
| find | locate files in a directory hierarchy |
| xargs | turn a list of files into a list of commands (and much more) |
| locate | create an index of files, and search the index for a string |
| which | locate executables in your search path (command) |
| type | locate executables in your search path (bash built-in) |
| whereis | locate executables, documentation, and source files |
Manipulating Text in Files
| command | description |
|---|---|
| grep | find lines in a file that match a regular expression |
| cut | extract columns from a file |
| paste | append text from multiple files in columns |
| column | organise text into columns |
| tr | translate characters into other characters |
| expand | convert from tabs to spaces |
| unexpand | convert from spaces to tabs |
| sort | sort lines of text by various criteria |
| uniq | local identical lines in a file |
| tac | reverse a file line by line |
| shuf | randomly shuffle the lines of a file (permutation) |
| tee | write to a file and print on standard output, simultaneously |
| awk | |
| sed | |
| m4 |
Compressing, Packing, Encrypting
| command | description |
|---|---|
| tar | package multiple files into a single file |
| gzip | compress files with GNU Zip |
| gunzip | uncompress GNU Zip files |
| bzip2 | compress files in BZip format |
| bunzip2 | uncompress BZip files |
| bzcat | uncompress BZip data to standard output |
| compress | compress files with traditional Unix compression |
| uncompress | uncompress files with traditional Unix compression |
| zcat | uncompress to standard output (gzip or compress) |
| zip | package and compress files in Windows Zip format |
| unzip | uncompress and unpack Windows Zip files |
| 7z | package and compress/uncompress 7-Zip files |
| munpack | extract MIME data to files |
| mpack | convert a file to MIME format |
| gpg | encrypt a file with the GNU Privacy Guard (GnuPG) |
Comparing Files
| command | description |
|---|---|
| diff | line-by-line comparison of two files or directories |
| comm | line-by-line comparison of two sorted files |
| cmp | byte-by-byte comparison of two files |
| shasum | compute checksums of the given files |
| md5sum | compute checksums of the given files (insecure) |
Converting Files to other formats
| command | description |
|---|---|
| pandoc | convert from one markup language to another |
| hxselect | extract information from an HTML file |
| jq | extract information from a JSON file |
| xmllint | validate and extract information from an XML file |
| csvtool | extract information from a comma-separated values (CSV) file |
| split | split up a file simply into multiple files |
| csplit | split up a file into multiple files using complex criteria |
PDF and Postscript File Handling
| command | description |
|---|---|
| pdftotext | extract text from PDF files |
| ps2ascii | extract text from PostScript or PDF files |
| pdfseparate | extract individual pages from a PDF file |
| pdftk | split, join, rotate, and otherwise manipulate PDF files |
| pdf2ps, pdf2pdf | convert between PDF and PostScript file formats |
| ocrmypdf | perform optical character recognition (OCR) on a PDF |
Spellchecking
| command | description |
|---|---|
| look | look up the spelling of a word quickly |
| aspell | interactive spelling checker |
| spell | batch spelling checker |
System Administration Basics
Viewing Processes
| command | description |
|---|---|
| ps | list processes |
| pgrep | list the IDs of processes that match a regular expression |
| uptime | view the system load |
| w | list active processes for all users |
| top | monitor resource-intensive processes interactively |
| free | display free memory |
Controlling Processes
| command | description |
|---|---|
| kill | terminate a process (or send it a signal) |
| pkill | terminate processes by name (or send them a signal) |
| timeout | kill a command that runs for too long |
| nice | invoke a program at a particular priority |
| renice | change a process’s priority as it runs |
| nohup | run a process that continues after you log out |
| flock | ensure that only one instance of a command runs at a time |
Scheduling Jobs
| command | description |
|---|---|
| sleep | wait a set number of secondns, doing nothing |
| watch | run a command at set intervals |
| at | schedule a job for a single, future time |
| crontab | schedule jobs for many future times |
Logins, Logouts, and Shutdowns
| command | description |
|---|---|
| systemctl | control the state of your machine and its services |
| shutdown | shut down your local machine |
| reboot | reboot your local machine |
Users and Their Environment
| command | description |
|---|---|
| logname | print your login name |
| whoami | print your current, effective username |
| id | print the user ID and group membership of a user |
| who | list logged-in users, long output |
| users | list logged-in users, short output |
| tty | print your terminal device name |
| last | determine when someone last logged in |
| printenv | print your environment |
User Account Management
| command | description |
|---|---|
| useradd | create an account |
| userdel | delete an account |
| usermod | modify an account |
| passwd | change a password |
| chsh | change a user’s shell |
Group Management
| command | description |
|---|---|
| groups | print the group membership of a user |
| groupadd | create a group |
| newgrp | use a new group membership immediately |
| groupdel | delete a group |
| groupmod | modify a group |
Installing Software Packages
| command | description |
|---|---|
| dnf | standard package manager for RPM files |
| yum | older package manager for RPM files |
| rpm | manipulate RPM packages locally |
| apt | standard package manager for DEB files |
| aptitude | alternative package manager for DEB files |
| dpkg | manipulate DEB packages locally |
| emerge | portable package manager for Gentoo Linux |
| pacman | package manager for Arch Linux |
| zypper | package manager for openSUSE Linux |
| flatpak | container-based package manager |
| snap | container-based package manager |
Installing Software From Source
| command | description |
|---|---|
| configure | prepare to build software manually with make |
| make | build software from source code |
Filesystem Maintenance
Networking Commands
Getting Stuff Done
Backlinks (2)
1. Wiki /wiki/
Knowledge is a paradox. The more one understand, the more one realises the vastness of his ignorance.
2. Shell/s /wiki/ccs/linux/shell/
There are many shells, all of them do the same thing — they allow you to manipulate your filesystem.
I have like all shells excluding Powershell1.
The Bourne shell (sh)
Origins
The Stephen Bourne Shell first appeared in Version 7 Unix (1979) at Bell Labs. It replaced the earlier Thompson shell and became the standard shell for Unix systems in the late 1970s and 1980s. Its design introduced structured programming features (variables, control flow) to improve on the limitations of older shells.