This is a collection of quick commands you can use to accomplish very specific tasks using the command line. This is a continuously growing collection, and contributions are accepted.
See the Table of Contents for a full guide.
ssh
connectionTo connect to some user
at remote server that has some ip
at the default port (port 22)
ssh user@ip
If successful, it will prompt for a password. For custom ports use the -p
flag.
The seamless way to access directories from a remote computer, like a server or cluster you need to constantly use is by mounting the remote directory into your filesystem. To do this, you will need sshfs
. On Linux install it via you package manager, on macOS you will need to follow this tutorial, and on Windows, figure it out yourself.
For Arch-based systems
sudo pacman -S sshfs
Then make some directory where you want to mount the filesystem, as an example
mkdir -p $HOME/remote-mnt/host
then simply
sshfs user@host:path/in/host/machine $HOME/remote-mnt/host
If successful it will prompt for your password, and your file manager like dolphin
or nautilus
should detect it immediately.
PS1
promptThe following bash function writes adds (branch)
at the end of your default prompt.
git_branch() {
git branch 2>/dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
Depends on ‘imagemagick’.
convert $(ls -v *.jpg) out.pdf
Combine images (frames) into a single video. Depends on ‘ffmpeg’
ffmpeg -framerate 30 -i %d.png -c:v libx264 -pix_fmt yuv420p output.mp4
in case it fails, you can try instead
ffmpeg -framerate 15 -i %d.png -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" -c:v libx264 -pix_fmt yuv420p output.mp4
Depends on ‘ffmpeg’.
ffmpeg -i video.mkv -codec copy video_out.mp4