Commands

From Computer Science
Revision as of 17:37, 9 February 2020 by Robert Lichenstein (talk | contribs) (Created page with " [pete](../../) > [guides](../) > [linux](./) > commands ---------------------------------------------------------------------- ===Introduction=== This page enumerates, cat...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search


[pete](../../) > [guides](../) > [linux](./) > commands


Introduction

This page enumerates, categorizes, and very briefly describes a bunch of Linux command-line programs that you may find useful. The documentation provided here is (intentionally) insufficient to actually use them; recall that you can use the `man` command to read the online manual page (arrow keys and pgup/pgdn scroll, 'q' to exit). Therefore, to read about all the options accepted by the `ls` program, run

Robert Lichenstein (talk) $ man ls Robert Lichenstein (talk)

Some of the programs below are standard, as part of the "coreutils" and "util-linux" packages in Arch Linux; others will need to be installed separately.

Vocabulary

Only one right now.

- "Recursive" refers to an operation that descends into child directories,

 their children, their children's children, and so forth.  Therefore,
 applying the '-r' parameter to `grep` will cause it to search not only the
 files in the current directory, but also all files within and below it.


    1. Commands

---

        1. The single most important one

- `man`: access the online manual

        1. The second most important one, for system administration

- `sudo`: run a program with temporarily-increased privileges

        1. Get me outta here

- `exit`: terminate the terminal session - `logout`: terminate the terminal session - `Ctrl-d`: terminate the terminal session (only when no other characters have

 been entered at the prompt; otherwise behaves as Enter)
        1. Basic filesystem stuff

- `pwd`: report the current working directory - `ls`: list information about files - `cd`: change to a different directory - `mkdir`: create a directory - `mv`: move a file (equivalent to renaming it, even if its new name puts it

 in a new directory)

- `cp`: copy a file - `rm`: remove a file - `rmdir`: remove a directory - `touch`: create a file or, if the file exists, update its modification

 time

- `chmod`: change permissions of a file - `chown`: change ownership (user/group) of a file - `ln`: create a (symbolic) link

        1. Text analysis

- `grep`: search inside file(s) - `wc`: count characters/words/lines in a file - `echo`: output a string to the terminal - `cat`: output the contents of a file to the terminal - `head`: print lines from the beginning of a file - `tail`: print lines from the end of a file - `diff`: compare the contents of files - `less`: allow keyboard-based scrolling through a file (manpages are run

 through `less`, thus the same navigation commands apply)
        1. Text manipulation

- `sort`: you'll never guess - `uniq`: filter out consecutive duplicate lines from a file - `cut`: combine files line by line - `paste`: separate files line by line - `sed`: modify files, line by line, according to regular expressions - `awk`: lightweight programming language for modifying files line by line - `fold`: break long lines into paragraphs - `fmt`: more complex version of `fold` - `column`: neatly format text into evenly-spaced columns

        1. More complex file stuff

- `find`: locate files based on metadata (eg, name, size, modification time) - `xargs`: often used to send the results of `find` to other programs - `tar`: create an archive containing multiple files - `gzip`: compress a file (historically ubiquitous) - `xz`: compress a file (more recently popular) - `stat`: report metadata information about a file - `dd`: copy file contents (more tweakable than `cp`, useful for copying from

 raw devices, eg, `/dev/urandom`)
        1. Measuring and monitoring

- `du`: measure sizes of files/directories - `time`: measure the runtime of a program - `ps`: list running processes (instant snapshot) - `top`: list running processes (updates repeatedly)

        1. Random

- `date`: report the date - `sleep`: pause for a configurable duration - `history`: list recently-run commands - `clear`: clear the terminal screen - `reset`: clear the terminal screen with extreme prejudice (useful if you

 want to erase the scrollback buffer or reverse text corruption when playing
 with, eg, customized fonts/colors in your shell)
        1. Network

- `ifconfig`: report information about network interface configuration

 (classic tool)

- `ip`: report information about network interface configuration (newer tool) - `route`: manipulate routing table - `netstat`: report information about network configuration - `ping`: check reachability of machines over the Internet - `traceroute`: trace the route to another machine on the Internet - `mtr`: trace the route to another machine on the Internet (my preferred

 choice)

- `netcat`: the Swiss Army Knife of the Internet - `wget`: save web pages as files - `curl`: save web pages as files (alternate)

        1. More complex

- `ssh`: log into a machine over the Internet - `rsync`: efficiently copies files (even across the Internet) - `tmux`: resumable terminal sessions - `script`: record the results of a terminal session in a file - `cron`: schedule programs to be run at certain times - `bc`: do math