Dup Ver Goto 📝

UsefulCommandLineTools

PT2/aw/os/shell does not exist
To
65 lines, 272 words, 1596 chars Page 'UsefulCommandLineTools' does not exist.

Environment

printenv

printenv # prints environment variables received from parent process
printenv VARNAME # prints VARNAME

Export

If a variable is not marked for export, it won't be received from the parent. printenv gives you a way to check what is being sent to subprocesses. To export a variable, use

export VARNAME

and you can also assign at the same time

export VARNAME=value

Date and time

date # prints date in human readable format
date +FORMAT # use FORMAT string (see manpage)
date +%s # print UNIX timestamp
TZ="Japan" date # print date and time in Japan

Processes

ps # list processes
pgrep <pattern> | xargs ps # list processes whose names match <pattern>

Jobs

bg # run job in background
fg # run job in foreground 
jobs # print current jobs
kill # send signal to process
kill -9 # immediately terminate process (process cannot intercept)
kill -15 # tell process to terminate (process can intercept)

Key combos

Ctrl-z # send SIGSTOP to current foreground process
Ctrl-c # Interrupt/terminate current foreground process
Ctrl-\ # Abort and core dump current foreground process

Find

find . -type f # find regular files
find . -type l # find symbolic links
find . -type d # find directories
find . -name \*x* # find files with an 'x' in their name (\* to avoid expansion)
find . -name \*x* -exec command params {} \; # execute command params filename for each file found