Commands


I am consolidating my commands that I have spread accross blog posts to just this one blog post. I’m going to maintain and update this post, so I’m not searching accross posts for how to do something!

Jupyter

Jupyter Notebook commands

Remote notebook setup

Here is how to launch Jupyter on a remote server and then view and use Jupyter as if you were running it locally.

On remote server, run this. (Need to be in the directory of the project with all dependencies installed obviously)

jupyter notebook --no-browser --port=8888

Locally. First make sure if the port has been previously bound to, that it’s unbound.

# unbind port
lsof -ti:8888 | xargs kill -9

# connect
ssh -N -f -L localhost:8888:localhost:8888 -i ~/.ssh/my.pem  username@hostname

Go to localhost:8888 in the browser and Jupyter should be loaded.

lsof

List all Process PIDs accessing a Port

lsof -ti:<port>

Kill all processes accessing a port

lsof -ti:<port> | xargs kill -9

kill

Kill a process by PID

kill -9 <pid>

Kill process by name

pkill -f <name-of-process>

wget

wget in background

wget -bqc url

ps

To see which ssh processes are running, this will show ssh port forwarding

ps aux | grep ssh

ls

count files in a dir - in order to check that the file count matches what was expected, or when the zip file didn’t fully download, or to check the image file count vs. expected.

ls -1 | wc -l

fastjar

If a zip file didn’t fully download, fastjar can be used to unzip it.

Trying to unzip the file will give you:

unzip error “End-of-central-directory signature not found”

Use fastjar if the whole zip file didn’t download:

sudo apt-get install fastjar
jar xvf something.zip

StackExchange reference

nvidia-smi

equivalent to “tail nvidia-smi”

# keeps passed traces
nvidia-smi -l 1

# doesn't keep past traces
watch -n0.1 nvidia-smi
# list usb ports and connected devices
lsusb

# configure network interfaces
ifconfig

# configure wifi network interfaces
iwconfig

# get detailed wifi info
iwlist <interface> s

# dynamic kernal support module
dkms

# ip show an manipulate routing, network devices, interfaces
ip link set <interface> up/down

# list hardware
lshw -C network

netplan apply

netplan --debug generate

# check if there's internet
ping -c3 www.ubuntu.com

nvidia-smi

# keeps passed traces
nvidia-smi -l 1

# doesn't keep past traces
watch -n0.1 nvidia-smi

Get fresh articles in your inbox

If you liked this article, you might want to subscribe. If you don't like what you get, unsubscribe with one click.