Linux / Bash commands + options that I need to look up here and there.
# Kernel version
uname -r
sudo visudo
# Change line
Defaults env_reset
# to
Defaults env_reset,timestamp_timeout={XX} # XX: time in minutes
some_cmd > output.log &
echo "Hello" > file.txt
grep -R # search dirs recursively from current dir
-F # normal string search (no regex)
-i # ignore case
-v # invert matching, only show non-matching lines
-w # string must be a word, i.e. preceded and followed by non-word
# constituent char (everything except letters, digits and _)
'my search term'
**/*.py # only search .py files
tree /my/dir
-a # print all files (hidden)
-d # only dirs
-C # use system colors for output
Find will only filter for file/dir names, not for file content.
find my/dir/path/ -name "*.txt" # Find all files in path with .txt extension.
sshfs {username}@{remote IP}:{remote dire to mount} {local dir to mount to}
# Example:
sshfs wierichs@137.226.133.156:/home/wierichs /home/anni/swarm1
ssh-keygen -d
Leave public key ~/.ssh/id_rsa.pub
at remote server. Key consists of everything in that file.
# If connecting for the first time, add remote to known hosts:
ssh-keygen -f "~/.ssh/known_hosts" -R IP
ssh IP_ODER_HOSTNAME -l LOGIN_NAME -i ~/.ssh/id_rsa
Ctrl D
Modules are stored in /usr/lib/modules/<kernel_release>
. \
To print kernel version: uname -r
lsmod # Show loaded modules
modprobe <module_name> # Load module
modinfo <module_name>
lspci -nn # List all PCI devices, also print vendor + device IDs
update-pciids # Run if some devices shown as "Unknown Device"
top # dynamic list
ps # static list, only with TTY
ps xf # static list, also without TTY
pstree # print process tree of the user
kill 5237 # kill process with ID 5237
netstat -tulpen # show all connections
sleep 100 & # or: sleep 100 -> Ctrl Z -> bg (for background)
jobs
# > [1]+ Running sleep 100 &
kill %1
nm -g yourLib.so # Display symbols if .so is not in elf format
objdump -T -C yourLib.so # Otherwise this...
readelf -Ws yourLib.so # ...or this.
ldd /usr/lib/yourLib.so # for a shared lib
ldd /usr/bin/firefox # for executable
vim ~/.bashrc
alias mynewgitcommand='git status'
source ~/.bashrc