Skip to content

Instantly share code, notes, and snippets.

@SuperShinyEyes
Last active January 15, 2018 19:06
Show Gist options
  • Save SuperShinyEyes/c1096ef64c8ab3e40518435181bce29e to your computer and use it in GitHub Desktop.
Save SuperShinyEyes/c1096ef64c8ab3e40518435181bce29e to your computer and use it in GitHub Desktop.
Bash commands

Packages...

apt-cache search name
apt-cache policy name
modinfo name
dpkg -l | grep name

puppet agent -t  // Update puppet list in /etc/apt/sources.list.d/name.list

Get GPU info

# 1. NVIDIA gpus
nvidia-smi

# 2. Display info
(sudo) lshw -C display

# 3. Device info
lspci  -v -s  $(lspci | grep ' VGA ' | cut -d" " -f 1)

You can inspect what packages are installed on Redhat based servers using the following command:

rpm -qa

See users on system

w
who

See processes

ps     // Only yours
ps -e  // Everyone's

For information about the disk systems one can use the following command:

// The filesystem.
df -h

Disk Usage:

// For any file or dir
du -sh *

Rename files in bulk

// ex.pdf? ---> ex.pdf
for f in *.pdf?; do mv "$f" "${f%?}"; done

Screenshot path

Now enter a space after "location" and drag the folder you created over to Terminal (which will insert the file path of the folder), or enter the location yourself.

defaults write com.apple.screencapture location
killall SystemUIServer

Get number of items in a dir

ls | wc -l
find . | wc -l
find . -type f | wc -l

Find files with text, pattern matching

// https://stackoverflow.com/a/16957078
grep -rnw '/path/to/somewhere/' -e 'pattern'

grep -rnw --exclude=\*.{html,js}  "Welcome"

Vim startup time

vim --cmd 'profile start profile.log' \
    --cmd 'profile func *' \
    --cmd 'profile file *' \
    -c 'profdel func *' 
    -c 'profdel file *' \
    -c 'qa!'

Get members of a group

getent group group-name
getent passwd user-name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment