commands and switches Flashcards
find [path] -name “[name]”
find files and subdirs
find [path] -type d -name “[dir]”
find subdirs
ldconfig –print-cache
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.
type [cmd]
Find whether the given command is an alias, shell built-in, file, function, or keyword. Also displays path
type -t [cmd]
Show just type
type -p [cmd]
Show just path
type -a [cmd]
Show all info
du [paths]
Disk usage
du -h [path]
Disk usage in human readable form
strace -f [program]
Trace child processes
strace -o “filename”
Output to log
strace -p PID
Attach
strace trace=open
Show opened files
rename ‘s/[old regex]/[new regex]/’
Batch rename
rename ‘s/-//’ ./*
remove dashes in all names in current folder: (1st dash)
grep [path] -e [pattern]
Search for pattern in path
grep -r
recursive
grep -n
display line number
grep -w
search for whole word
grep -l
show just file names
[[ -a file ]]
Test if file/dir exists. Identical to -e
[[ -d file ]]
Test if directory exists
[[ -f file ]]
True if file exists and is a regular file.
[[ -e file ]]
Test if file/dir exists. Identical to -a
[[ -r file ]]
True if file exists and is readable
[[ -s file ]]
True if file exists and has a size greater than zero.
[[ -w file ]]
True if file exists and is writable
[[ -x file ]]
True if file exists and is executable
[[ file1 -nt file2
]]
True if file1 is newer than file 2
[[ file1 -ot file2 ]]
True if file1 is older than file2