Show Menu
Cheatography

Administración de sistemas Cheat Sheet by

Useful commnads and programs

Sections of man pages

1
User-level commands and applic­ations
2
System calls and kernel error codes
3
Library calls
4
Device drivers and network protocols
5
Standard file formats
6
Games and demons­tra­tions
7
Miscel­laneous files and documents
8
System admini­str­ation commands
9
Obscure kernel specs and interfaces

Substi­tution order

1. Redirect I/O
2. Replace {} expansion
3. Replace `~` expansion
4. Params and variable expansion
5. Commnad $() substi­tution
6. Arithmetic expansion
7. Process <() substi­tution
8. Word splitting (IFS)
9. File name expansion

wget(1)

-q, --quiet
Turns off Wget's output
-B, --base
Relative links using URL
-t, --tries
Set number of retries
-O {file|-}
Redirect output
-T, --timeout
Network timeout to seconds

date(1)

-d, --date=
Display time described, not now
-s, --set=
Set time to described ¡
%a, %A
Sun, Sunday
%b, %B
Jan, January
%c
Thu Mar 3 23:05:25 2005
%d
day of month
%F
full date; same as
%Y-%m-%d
%H, %I
hour (00..23), hour (01..12)
%m
month (01..12)
%M
minute (00..59)
%s
seconds since epoch
%S
second (00..60)
%T
time; same as
%H:%M:%S
%Y
Year

tar(1)

-c, --create
create new
-r, --append
append files
-t, --list
list the contents
-u, --update
only append newer
-x, --extract
extract files
-C, --dire­ctory=
change to directory
-f, --file=
use archive file or device
-j, --bzip2
bzip2
-z, --gzip
gzip

sort(1)

-b
ignore leading blanks
-d
only blanks and alphan­umeric
-f
case insens­itive
-i
ignore non-pr­intable
-M
compare 3-letter month
-h
human numeric (2K < 1G)
-n
numeric
-R
random short (hash)
-r
reverse result, i. e. descending
-k
Key start at pos (origin 1)
-u
Delete duplicates
-z
Zero terminated lines

read(1)

-p prompt
Shows prompt text
-r
One line only (no backslash)
-s
Silent. No echo.
-t
Timeout in seconds
-u fd
Read from file descriptor
-n
Number of chars
-d
Set delimiter

du(1)

-a
All files (not just dirs)
--file­s0-­from=
Null separated. '-' is stdin
-h
Human readable
--max-­depth
'0' => just given argument

lvm(8) - pv / vg / lv

~change
Change attributes
~create
Initialize for use by LVM.
~display
Display attributes
~resize
Resize a LVM ~
~extend -L
Extends ~ by [+]bytes
~scan
Shows all LVM ~
Tips:
mkfs -t ext3 part
/
resize2fs lv_name

/etc/p­asswd

login:­pas­swd­:UI­D:G­ID:­inf­o:h­ome­:shell

/etc/s­hadow

login:­pas­swd­:la­stc­han­ge:­min­tim­e:m­axt­ime­:wa­rnt­ime­:de­tim­e:l­cktime:

passwd(1)

-e
Expire date
-d
Delete password
-l, -u
Lock or unlock
-n
Min days between changes
-x
Max days of validity
-w
Warn days before expire
-i
Deactivate days
-S
Show status of account

/etc/group

name:p­ass­wd:­GID­:lo­gin­-list
 

Shell and tools (I)

type
Shows type of the program or command given as first paramether
stty
Change and print terminal line settings
chpasswd
Reads from stdin pairs of type USER:P­ASSWORD
id
Returns user info
uid=10­00(­name) gid=10­00(­name)
. Exit code is set.
bc
Math expresions from stdin. Tip: use
scale=n;
for div precision
seq
[FISR [INCRE­MENT]] LAST

Shell and tools (II)

cat
who
whoami
head
echo
cp
mv
ln
mkdir
rm
rmdir
ln -s
cat
less
more
bg
tee
exec
jobs
fg
env
printenv
readonly
export
local
$(())
pwd
ls
paste
uniq
wc -l
fmt
join
split
tac
rev
nl
expand
od
chown
chgrp
chmod
passwd
useradd
userdel
usermod
groupadd

find(1) [OPTIONS]

-maxdepth
Descend at most levels
-mindepth
No actions at less than levels

find(1) [TESTS]

+n, -n, n
greater, less, exactly n
-amin n
Last accessed n minutes ago
-atime n
Last accessed n days ago
-cmin, -ctime n
Last changed
-mmin, -mtime n
Last modified
-empty
Empty regular or directory
-execu­table
File or directory +x
-group gname
File belongs to group
-gid n
Numeric group ID
-user uname
File belongs to user
-uid n
Numeric user ID
-name
Base name matches pattern
-iname
-name, but case insens­itive
-path
File name matches pattern
-perm mode
Permission bits are...
g=u, +g=u, /g=u
exactly, at least, any of
-size n[cwbkMG]
File uses space
-type [bcdpfls]
File is of type
-readable
With read permission
-writable
With write permission

find(1) [ACTIONS]

-delete
Delete files
-exec cmd;
Execute for every file (multiple {})
-exec cmd+
Execute appending file (single {})
-fprint
Print into file
-ok cmd ;
Like -exec, but ask user first
-print0
Null seperated
-printf
Print with format

cut(1)

-b
Select bytes
-c
Select characters
-f
Select fields
-d
Field delimiter
--comp­lement
Complement selector
N, N-, N-M, -M
Specifies selector

ping(8)

-c
Number of requests

tail(1)

-c K
Bytes to print
-n K
Lines to print
K
May have sufix (b, kB, K...)
+K
Print from...

ps(1)

-e
All process
-a
All except leaders and no-ter­minal
-g
By group
-p
By pid
-t
By tty
-u
By user
-F
Full output format
-o
Custom output format

wc(1)

-l
Number of lines
-w
Number of words
-c
Number of bytes
-L
Length of longest line

Predefined variables

$0
Program name
$1-$9
Normal params
${10}, ${11}...
More params
$#
Number of params
$*
List of params
$@
List of params (*)
$?
Exit status code
$$
Process id
$!
Last child process id
(*) Use "­$@" when reading in for-loop

/etc/s­udoers

user ALL=ALL
%group ALL=NO­PAS­SWD­:/u­sr/­bin­/true
 

Shell and tools (III)

if cond; then
[elif cond; then]
else
fi

IF=$' \t\n'
while cond
do
[break | continue]
done

until cond

for i in list
do
done

Shell special characters

'
"
\
&
<
>
<<
>>
*
|
?
[ ]
[!^ ]
$
;
`
Between " " only $, `cmd` and \

Extended regex

.
[ ]
[^ ]
^
$
*
( )
\
{n,m}
+
?
\w
\s
\b
\B

egrep(1)

-e
Specifies the pattern
-f
Get patterns from file lines
-i
Case insens­itive
-v
Select non-ma­tching lines
-w
Match whole words only
-c
Show (non-)­mat­ching lines count
-q
Quiet (exit 0 when match)

test(1)

( EXPRESSION )
is true
! EXPRESSION
is false
EXP -a EXP
Logic AND
EXP -o EXP
Logic OR
-n STRING
Not null string
-z STRING
Null string
STR = STR
Strings are equal
STR != STR
Strings are different
INT -eq INT
Numbers are equal
INT -ne INT
Numbers are different
-ge, -gt
>=, >
-le, -lt
<=, <
FILE1 -ef FILE2
Same device and inode
FILE1 -nt FILE2
F1 is newer than F2
FILE1 -ot FILE2
F1 is older than F2
-b, -c, -d, -f
block, chars, dir, regular
-e, -r, -w, -x
exists, read, write, exec
-t FD
File descriptor FD is opened

stat(1)

-c
Specifies output format
%a, %A
Access rights octal, human
%b, %s
Size in block, bytes
%F
File type
%g, %G
Group owner id, name
%h
Number of names (links)
%i
Inode number
%n, $N
File name, quoted
%t, %T
Device major, minor
%u, %U
User owner id, name
%x, %X
Last access time, epoch
%y, %Y
Last modified time, epoch
%z, %Z
Last changed time, epoch

tr(1)

-c
Use complement of SET1
-d
delete chars from SET1
Transl­ation occurs if -d is not given and both SET1 and SET2 appear. SET2 is extended to length of SET1 by repeating its last character as necessary. Excess characters of SET2 are ignored.

sed(1)

-e cmd
Multi-­command mode
=
Current line number
`a`
Append text
`i`
Insert text
`c`
Replace lines
d
Delete pattern
s
Replace pattern
g
Apply globally (more than once)
[ line_n [ ,line_n ] ] commnad [ parameters ]

! line_n command [param­eters]

[ line_n, $ ] commnad [ parameters ]

ps(1) [FORMAT]

pid
state
user
ruser
group
rgroup
pid
ppid
pgid
pcpu
nice
etime
time
tty
comm
args

xargs(1)

-i
permite el uso de {}
-r
No run if empty
--null, -0
Null terminated args
-d
Delimiter
-n
Max args
           
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Linux Every Day Commands Cheat Sheet