commands and switches Flashcards

(75 cards)

1
Q

find [path] -name “[name]”

A

find files and subdirs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

find [path] -type d -name “[dir]”

A

find subdirs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

ldconfig –print-cache

A

Print the lists of directories and candidate libraries stored in the current cache. Pipe into grep to find if a particular library is installed and accessible.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

type [cmd]

A

Find whether the given command is an alias, shell built-in, file, function, or keyword. Also displays path

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

type -t [cmd]

A

Show just type

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

type -p [cmd]

A

Show just path

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

type -a [cmd]

A

Show all info

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

du [paths]

A

Disk usage

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

du -h [path]

A

Disk usage in human readable form

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

strace -f [program]

A

Trace child processes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

strace -o “filename”

A

Output to log

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

strace -p PID

A

Attach

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

strace trace=open

A

Show opened files

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

rename ‘s/[old regex]/[new regex]/’

A

Batch rename

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

rename ‘s/-//’ ./*

A

remove dashes in all names in current folder: (1st dash)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

grep [path] -e [pattern]

A

Search for pattern in path

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

grep -r

A

recursive

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

grep -n

A

display line number

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

grep -w

A

search for whole word

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

grep -l

A

show just file names

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

[[ -a file ]]

A

Test if file/dir exists. Identical to -e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

[[ -d file ]]

A

Test if directory exists

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

[[ -f file ]]

A

True if file exists and is a regular file.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

[[ -e file ]]

A

Test if file/dir exists. Identical to -a

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
[[ -r file ]]
True if file exists and is readable
26
[[ -s file ]]
True if file exists and has a size greater than zero.
27
[[ -w file ]]
True if file exists and is writable
28
[[ -x file ]]
True if file exists and is executable
29
[[ file1 -nt file2 | ]]
True if file1 is newer than file 2
30
[[ file1 -ot file2 ]]
True if file1 is older than file2
31
[[ -v varname ]]
True if the shell variable varname is set (has been assigned a value).
32
[[ -z string ]]
True if the length of string is zero
33
[[ -n string ]]
True if the length of string is non-zero
34
[[ arg1 -eq arg2 ]]
Arithmetic are equal
35
[[ arg1 -ne arg2 ]]
Arithmetic not equal
36
[[ arg1 -lt arg2 ]]
Arithmetic less than
37
[[ arg1 -le arg2 ]]
Arithmetic less or equal
38
[[ arg1 -gt arg2 ]]
Arithmetic greater than
39
[[ arg1 -ge arg2 ]]
Arithmetic greater or equal
40
[[ arg1 == arg2 ]]
String equality
41
[[ arg1 != arg2 ]]
Strings different
42
[[ arg1 < arg2 ]]
String 1 is lexicographically before string 2
43
ls -l
long listing format
44
ls -A
Almost all files: with hidden, no ./..
45
ls -a
all files: hidden, ./..
46
tail -F some.log
Track while adding
47
rm -f
remove file force: no confirmation
48
file [full path]
auto detect file type
49
ldd [full path]
show static .so dependencies
50
wc
word count
51
wc -l
word count, just lines
52
lsof
list open files
53
lsof +D [path]
list open files within directory
54
lsof +r 5
list open files, refresh every 5 sec
55
ps
active processes by my user
56
ps -u guga
all active processes by user guga
57
uniq -c
Show count of unique entries in *sorted* input
58
sort [file]
sort lines
59
tcpdump -qns 0 -r [file]
dump pcap contents - q: quiet, less protocol info - n: don't convert ip to names - s [X]: snap X bytes of data from the packet. -s 0: don't display the packet - r: read [file]
60
grep -o
Print only matching parts of a matching line
61
grep -P
Pattern is a perl-compatible regex
62
xargs -n 1
--max-lines=1 : use at most 1 argument per command line
63
xargs -t
synonym to --verbose, show all commands
64
xargs -I % (capital i)
replace % with the input. Doesn't have to use % as the replace-str
65
xargs -P 7
run at most 7 processes
66
find /tmp -name core -type f -print0 | xargs -0 /bin/rm -f
Find files named core in or below the directory /tmp and delete them, processing filenames in such a way that file or directory names containing spaces or newlines are correctly handled.
67
remote copy (directory)
scp -r username@from_host:/remote/directory/ /local/directory/
68
ls only folders
ls -d */ | huh?
69
in htop, show open files
l
70
in htop, strace
s
71
processor bar colors in htop
Blue/green/red: low-pri/normal/kernel threads
72
Memory bar colors in htop
Green/blue/yellow: used/buffer/cache
73
in htop, show env
e
74
xargs show commands
--verbose, -t
75
xargs confirm each command separately
--interactive