awk '/<pattern>/{for (i = 1; i <= NF; ++i) print i, $i; exit}' <fileName>To find out your current network devices' status
nmcli device statusTo find out all the useful numbers about our <net dev> (say, eth0)
nmcli device show <net dev> | grep -e IP4.DNS -e IP4.GATEWAY -e IP4.ADDRESSThe IP4.ADDRESS[1] field carries information about the subnet mask too.
If we prefer a more extended version
ifconfig <net dev> | awk '/Mask:/{print $4}'After having run jupyter notebook on the remote machine R, keep track of the remote port R_port (e.g. 8888) and Jupyter token J_token (e.g. a1b2c3d4).
On your local machine L bind a L_port (e.g. 9000) to where Jupyter is running at on R.
l@L ~ $ ssh -NfL L_port:localhost:R_port r@RFinally, on L, go to http://localhost:L_port/?token=J_token, and you should be able to use the notebook remotely.
To close the ssh tunnel, you can ps aux | grep ssh, take note of ssh_PID and kill ssh_PID.
column -ts, <fileName.csv>Or, from Vim
:read !column -ts, <fileName.csv>All users:
sudo lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,LABELCurrent user (FSTYPE and LABEL available only with sudo):
lsblk -o NAME,SIZE,MOUNTPOINTudisks --mount <deviceName>or
udisksctl mount -b <deviceName>
grep -Inri "<keyword to search for>" .find . -type f -exec sh -c "echo '{}'; cat {}; echo '\n'" \;find . -maxdepth 1 -type d -exec sh -c "echo {} \`ls {} | wc -l;\`" \;or, better
ls -d */ | while read dir; do
echo "$dir: $(ls $dir | wc -l)"
donegroups <user>groupadd <group>
usermod -aG <group> <user>or
adduser <user> <group>chmod g+s <folder>find <folder> -type d -exec chmod g+s {} +a@A ~ $ ssh-keygen -t rsa
a@A ~ $ ssh b@B mkdir -p .ssh
a@A ~ $ cat ~/.ssh/id_rsa.pub | ssh b@B 'cat >> .ssh/authorized_keys'
a@A ~ $ ssh b@Bps -a | grep <program to kill>
kill 9 <ID of program to kill>du -chs *df -h [<path>]/usr/bin/time -v <running instruction>tar -czf myTar.tar.gz <files>
tar -xf myTar.tar.gzAdd -v for verbose output.
who -u
kill "pid"apt-cache pkgnames <packagePrefix>To know more, e.g. whether the packages are installed,
apt list <packagePrefix>*dpkg -L <packageName>lld <library/executable>git fetch origin
git reset --hard origin/mastergit reset --hardgit log --decorate --graph -p -- fileName
git blame fileNamegit clean -dfIf the repo has sumbodules, then
git submodule foreach git clean -dfgit diff --word-diffor, on older versions,
git diff --color-words -U9999999git fetch -pgit update-index --assume-unchanged <file>
git update-index --no-assume-unchanged <file>For example, to loose track of the status of your notebook you can git update-index --assume-unchanged notebook/*.ipynb.
To list all assumed unchanged files type
git ls-files -v | egrep '^h'git log --follow <fileName>Edit .git/info/exclude as you would for .gitignore.
git diff: what you can still add to the index;git diff --cached: what you have on the index vs. what's committed;git diff HEAD: everything that has not been committed (working dir + index);git diff <commit>: working tree −<commit>;git diff --cached <commit>: index −<commit>;git diff <commitFrom> <commitTo>:<commitTo>−<commitFrom> (chronological order!);git diff <commitFrom>..<commitTo>: same;git diff <commitFrom> <commmitTo> --stat: summary of changes;git diff <commitFrom> <commmitTo> -- <filename>: changes per<filename>only.
git add <filename>: copies a file from the working dir to the index;git commit ...: copies a file from the index to (a new) HEAD;git reset <filename>: copies a file from HEAD to the index (i.e. removes file from index);git checkout <filename>: copies a file from the index to the working dir (i.e. removes local changes);git checkout -- '*.c': copies all C files (even removed one) from the index to the working dir.
:setfiletype CTRL-D:%s/\s\+$<c>-R 0:Ex
:Sexq:
q/:grep -rI "<text>" .
:cw:diffg RE/BA/LO[c ]c
move-window -t <nb>
tmux attach -d
Show and hide hidden files in Finder
defaults write com.apple.finder AppleShowAllFiles TRUE
defaults write com.apple.finder AppleShowAllFiles FALSE
killall Finder
ffmpeg -framerate 30 -i <path>/%03d.png -pix_fmt yuv420p -filter:v "crop=floor(iw/2)*2:floor(ih/2)*2" video.mp4
texdoc <package name>
tlmgr update --all