|
|
|
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 |
