100% found this document useful (1 vote)
60 views2 pages

Bash

The document provides an overview of various Linux/Bash commands organized into sections on file system commands, process commands, user environment commands, text processing commands, and more. It describes the functionality and usage of commands like cat, ls, grep, awk, tar, and others.

Uploaded by

doldies
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
60 views2 pages

Bash

The document provides an overview of various Linux/Bash commands organized into sections on file system commands, process commands, user environment commands, text processing commands, and more. It describes the functionality and usage of commands like cat, ls, grep, awk, tar, and others.

Uploaded by

doldies
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Linux/Bash notes source: https://git.

io/vMQlp

1 Unix utilities and shell builtins  du estimates file space usage: F nice changes process priority.
a writes counts for all files, not just directories,
F pgrep, pkill looks up or signals processes based
1.1 File system c produces a grand total,
on name and other attributes.
d the depth at which summing should occur,
 cat concatenates and prints files: h prints sizes in human readable format, F time runs programs and summarizes system re-
A shows all nonprinting characters, s diplays only a total, source usage.
b numbers nonempty output lines, X excludes files that match pattern.
F top displays linux processes.
n numbers all output lines,
F file determines file type.
s suppresses repeated empty output lines.
 tac does the same in reverse. F fsck checks and repairs a Linux filesystem: 1.3 User environment
F rev reverses lines characterwise. a automatically repairs (without any question!), F clear clears the terminal screen.
 nl numbers lines of files: t specifies the type(s) of filesystem to be checked, F env runs a program in a modified environment.
s adds string after line number, A tries to check all filesystems in one run, F exit terminates the calling process.
w uses number columns for line numbers. M skips mounted filesystems, F finger looks up user information.
R skips the root filesystem. F history displays the history list.
 chgrp changes group ownership.
 ln makes hard links between files (not directories; F mesg displays messages from other users.
 chmod changes permissions of a file:
ugoa permissions of the owner, group, other/all users, only in the same file system): F passwd changes user password:
+-= adds, removes or sets selected file mode bits, s makes symbolic links instead. d deletes an accounts password (makes it empty),
rwx selects file mode bits: read/write/execute (4/2/1).  ls lists directory contents: e expires an accounts password,
 chown changes owner of a file. a does not ignore entries starting with dot, n sets minimum days to change password,
F umask sets file mode creation mask. F appends indicator to entries, w sets warning days before password expire,
 touch changes file timestamps: h prints human readable sizes, x sets the maximum number of days a password re-
a only the access time, i prints the index number of each file, mains valid.
m only the modification time, l prints permissions, number of hard links, owner, F su changes user ID or becomes superuser.
t uses custom stamp instead of current time, group, size, last-modified date as well, F sudo executes a command as another user.
c does not create files. r reverses order while sorting,
R lists subdirectories recursively, F uname prints system information:
 shasum prints or checks SHA message digests: a all information, in the following order:
a algorithm: 1, 224, 256, 384, 512, 512224 or 512256, S sorts by file size (largest first),
t sorts by modification time (newest first), s the kernel name,
b reads in binary mode, n the network node hostname,
c checks SHA sums read from the files. F tree folds lower case to upper case characters.
r the kernel release,
 See also cksum (CRC checksums) and md5sum. F mount mounts a filesystem. v the kernel version,
 wc prints newline, word and byte counts (lwc): m the machine hardware name,
m prints the character counts,  pwd prints name of current directory.
p the processor type,
L prints the maximum display width. F tar stores and extracts files from a disk archive: i the hardware platform,
c creates a new archive, o the operating system.
 dd converts and copies a file:
x extracts files,
if= reads from a file instead of standard input, F uptime: how long has the system been running?
t lists the contents of an archive,
of= writes to a file insteaed of standard output,
v verbosely lists files processed, F wall writes a message to all users,
bs= up to bytes bytes at a time,
j bzip2 compression, F write sends a message to another user.
count= copies only n input blocks.
z uses zip/gzip (gz compression),
f uses archive file or device (???), F who shows who is logged on,
 cp copies files and directories:
k does not replace existing files when extracting. F w does the same and shows what they are doing,
b makes a backup of each existing destination file,
F whoami prints effective userid.
f removes an existing destination file if needed,  tee duplicates pipe content:
i prompts before overwrite, a appends to the given files, does not overwrite,
n does not overwrite existing files, 1.4 Text processing
i ignores interrupts.
L always follows symlinks in source, F awk is a pattern scanning / processing language,
P never follows symlinks in source, F Missing: cmp, fuser, pax, type. a pseudo-C interpretor. Sample code:
r copies directories recursively,
s makes symbolic links instead, 1.2 Processes 1 BEGIN {print "- Start -"}
l hard links files instead, 2 /word/ {print NR ")" $1, $2}
t copies all source arguments into directory, F chroot changes the root directory for the current 3 END {print "- End -"}
T treats destination as a normal file, running process and their children.
u copies only newer source files, Examples of conditions:
F at schedules commands to be executed once, at (a) /word[0+9]+/: regular expressions
v explains what is being done. a particular time in the future: it accepts times
 mv moves (renames) files: (b) !/word[0+9]+/: regexes inverted
of the form HH:MM, midnight, noon or teatime; (c) and !: matches / does not match.
b makes a backup of each existing destination file, MMDD[CC]YY, MM/DD/[CC]YY, DD.MM.[CC]YY or
i prompts before overwriting, (d) length($0) > 18.
[CC]YY-MM-DD (the specification of a date must Important variables:
f does not prompt before overwriting, follow the specification of the time of day). You
n does not overwrite existing destination files. (a) FS: field separator (tab),
can also give times like now + 3 hours. (b) OFS: output field separator,
t moves all source arguments into directory,
T treats destination as a normal file, F bg resumes suspended jobs in the background. (c) RS: record separator (new line),
u moves only newer source files, F fg resumes suspended jobs in the foreground. (d) NR: number of the current record,
v explains what is being done. F jobs lists the active jobs. (e) NF: number of fields in the current record.
 rm removes files or directories: F command & runs command in the background. F grep prints lines matching a pattern:
f never prompts, c prints a count of matching lines instead,
F cron: a daemon executing scheduled commands. e uses a regexp pattern,
i always prompts,
F crontab maintain individual users crontab files. f obtains patterns from a file,
r removes directories and their contents.
 See also rmdir (directories removal). F kill sends a TERM signal to a process. i ignores case disctinctions,
 mkdir makes directories (mkdir p: with parents F killall kills processes by name. v inverts the sense of matching,
as needed, no error if existing). w selects only lines containing matches that form
F ps reports a snapshot of the current processes: whole words,
 df reports file system disk space usage: e selects all processes, n prints line numbers as well,
h prints size in powers of 1024, f does full-format listing, A prints num lines of trailing content,
i list inode information instead of block usage, C selects processes by command name, B prints num lines of leading content,
t limits listing to file systems of given type, p selects processes by PID, C prints num lines of both contents,
x limits listing to file systems not of given type, u selects processes by EUID or name. R ???,
T prints file systems types. F pstree displays a tree of processes. F sed: a stream editor filtering/transforming text.

page 1/2 author: Remigiusz Suwalski, date: January 21, 2017


Linux/Bash notes source: https://git.io/vMQlp

 comm compares two sorted files line by line. f outputs appended data as the file grows, F route shows and manipulates the IP routing ta-
 shuf generates random permutations: s sleeps for n seconds between iterations. ble.
e treats each arg as an input line,  split splits a file into pieces: F ssh is an OpenSSH SSH client (remote login pro-
i treats each number .. through .. as an input line, a generates suffixes of length n (default 2), gram).
n outputs at most count lines, b puts size bytes per output file, D (bind address)
r output lines can be repeated (with -n). d uses numeric (not alphabetic) suffixes, p (port)
 sort sorts lines of text files: l puts number lines/records per output file, X (X11 forwarding)
c checks for sorted input, n generates chunks output files. F traceroute is a computer network diagnostic tool
f folds lower case to upper case characters,  See also: csplit. for displaying the route (path) and measuring
g compares general numerical values, transit delays of
F less is opposite of more.
h compares human readable numbers, F wget is a non-interactive network downloader.
F more is a file perusal filter for crt viewing.
k sorts via a key, A, R specifies lists of file suffixes or patterns (when
n compares string numerical values, F xargs builds and executes command lines from wildcard characters appear) to accept or reject,
r reverses the results, standard input. b goes to background immediately after startup,
s stabilizes the sort. c continues getting a partially-downloaded file,
F yes outputs a string repeatedly until killed.
 tsort performs topological sort. m turns on options suitable for mirroring: infinite
 uniq omits repeated lines: recursion and time-stamping,
c prefixes lines by the number of occurences, 1.5 Shell builtins np does not ever ascend to the parent directory when
d only prints duplicate lines, one for each group, F alias allows a string to be substituted for a word. retrieving recursively,
f avoids comparing first fields, F cd changes the shell working directory: U identifies as agent-string to the HTTP server.
i ignores differences in case, - to the previous directory. w waits the specified number of seconds between
s avoids comparing first characters, F echo* displays a line of text: the retrievals (see also random-wait).
w compares no more than n characters. e enables interpretation of backslash escapes,
n does not output the trailing newline.
 cut prints selected parts of lines: F test checks file types and compares values.
1.7 Searching
--complement complements the selection, F unset unsets a shell variable, removing it from F find searches for files in a directory hierarchy.
c selects only these characters, memory and the shells exported environment.
d uses delim instead of Tab for field delimeter, F locate finds files by names.
F wait waits for process to change state. F whatis displays one-line manual page descrip-
f selects only these fields,
s does not print lines not containing delimeters. tion.
 join joins lines of two files on a common field. 1.6 Networking F whereis locates the binary, source, and manual
 paste merges lines of files. F curl transfers a URL. page files for a command.
d reuses characters from list instead of tabs, F dig is a DNS lookup utility (domain information
s pastes one file at a time, not in parallel. groper). 1.8 Miscellaneous
 tr translates or deletes characters: x simplified reverse lookups.
c uses the complement of set1, F host is a DNS lookup utility. F bc is an arbitrary precision calculator language.
d deletes characters, does not translate, F ifconfig configures a network interface. 1. echo obase=16;255 | bc prints FF,
s replaces each sequence of a repeated character F inetd is a super-server daemon that provides In- 2. echo ibase=2;obase=A;10 | bc prints 2,
that is listed in the last specified set with a single ternet services. 3. scale=10 (after bc -l) sets working precision.
occurrence of that character. F netcat: arbitrary TCP and UDP connections and F dc is a reverse-polish desk calculator. One of the
listens. oldest Unix utilities, predating even the invention
F diff compares files line by line: F netstat prints network connections, routing ta- of the C programming language.
y outputs in two columns, bles, interface statistics, masquerade connec- F cal, ncal displays a calendar.
i ignores case differences, tions, and multicast memberships. e displays date of Easter,
w ignores all white space. F nslookup queries Internet name servers interac- j displays Julian days,
F fmt is a simple optimal text formatter, tively. m displays the specified month,
F fold wraps each line to fit in specified width. F ping tests the reachability of a host on an IP net- w prints the numbers of the weeks,
work by sending ICMP ECHO_REQUEST: y displays a calendar for the specified year,
 head outputs the first (last) part of files: c stops after sending count packets, 3 displays the previous, current and next month.
c the first num bytes, n numeric output only, avoids to lookup symbolic F date prints or set the system date and time.
n the first num lines, names for host addresses. F lp prints files.
 tail the last num bytes: F rdate sets the systems date from a remote host. F od dumps files in octal.
c the last num bytes, F rlogin is an OpenSSH SSH client (remote login F sleep delays for a specified amount of time.
n the last num lines, program) F true, false does nothing, (un)successfully.

page 2/2 author: Remigiusz Suwalski, date: January 21, 2017

You might also like