## Brie Carranza's UNIX-y cheatsheet ## # TiBS bustatus == /usr/sbin/tera -Q ## View TiBS.ini grep -v "^#" /etc/tibs/tibs.ini | sed '/^$/d' # Extract a tarball without all the directory structure tar zvxf whatever.tar.gz --strip-components 5 # View the default printer lpoptions lpq # Print four pages on one sheet of paper lpr -Pscs_public -o number-up=4 file.txt # Fix system time on a VM ntpdate clock-1.cs.cmu.edu hwclock --systohc # Check the hardware clock time hwclock -r # Query xrandr for available outputs xrandr -q # Rotate the screen xrandr --output DVI-I-1 --rotate left # What files does an RPM file provide? rpm -qlp fool.rpm # What files does a package provide? rpm -ql package-name # What package provided a file? yum provides /path/to/file* # Report all current u(ser)limits ulimit -a # One of a million ways to check if a given Perl module is available and it's current version /usr/bin/perl -MCPAN -e 'install Email::Send' # Ubuntu LTS Release names # 18.04 Bionic Beaver # 16.04 Xenial Xerus # 14.04 Trusty Tahr # 12.04 Precise Pangolin # 10.04 Lucid Lynx (EOL) # Date the way you like it # 2016-03-March-10 date +%Y-%m-%B-%d # Unban an IP via fail2ban-client # Get the name of the jail fail2ban-client status # Unban fail2ban-client set sshd unbanip 8.8.8.8 # Change user's full name chfn -f "Edward Xample" example # Are ports 80 and 443 open? nc -v -z cs.cmu.edu 80 443 ############## # VBoxManage # ############## # List all VMs on a host VBoxManage list vms # Take a snapshot of a guest /usr/bin/vboxmanage snapshot "compute-0-1" take snap-$(date +%Y-%m-%B-%d-at-%H-%M) --description "This snapshot was taken automatically at $(date). Brie created this script in February 2017." --live # Turn a guest off rudely VBoxManage controlvm "Rocks-Compute-0-0" poweroff # Extract the .spec file from a source RPM rpm2cpio myrpm.src.rpm | cpio -civ '*.spec' # Extract the files inside the RPM rpm2cpio ./whatever.rpm | cpio -idmv # To view a list of available shells, you can run: ldapchsh -l # To set your shell to /bin/bash, you would run: ldapchsh -n /bin/bash # To view network interface info nmcli dev show eno1 <-- Ubuntu 16.04 nmcli dev list iface em0 <-- Ubuntu 14.04 and earlier # Neatly print mounted filesystems column -t < /proc/mounts ######### # ROCKS # ######### # Rebuild a compute node rocks run host compute-X-Y "/boot/kickstart/cluster-kickstart-pxe" # Configure a compute node to rebuild at next PXE boot rocks set host boot compute-0-0 action=install # Query Ganglia info using ROCKS commands rocks report host ganglia gmond compute-0-0 # Configure a node to run memtest when it reboots rocks set host runaction compute-0-38 action=memtest # Check on the status of a compute node as it rebuilds # using this command or SSH on port 2200 rocks-console compute-0-0 # ROCKS requires a minimum amount of RAM in order to install a compute node. That value is higher than 400 MB but lower than 700 MB. # Unable to get /share/apps mounted properly on a new 6.1.1 cluster? mount --rbind /export /share # I am impatient and want to access the filesystem on a compute node while it rebuilds. cd /mnt/sysimage # X session on compute node # Some resources will tell you to set ForwardX11Trusted to yes in /etc/ssh/ssh_config # While this will work, you can instead: ssh -Y head-node ssh -Y compute-node # Query 411 manually /opt/rocks/bin/411get --master http://10.1.1.1:372/411.d --verbose --list-project-info ####### # MPI # ####### ## Do your version of OpenMPI "hello, world" ## Each node in the file mpihosts will work on the job of printing the results of the hostname command ## You will see eight hostnames mpirun -np 8 --hostfile mpihosts hostname ## What version of OpenMPI do I have? ompi_info ######### # SLURM # ######### # Get an interactive list of the state of jobs, their owners, statuses, job IDs smap -i2 # View nodes in DRAIN state (draining or drained) and info about why they are in that state (try with --noheader) sinfo -R # View all jobs since February 1st sacct -S 0201 # Drain a node, Reason is required, a good reason is recommended # There is a twenty character limit for the reason. # You can use the same command to update the reason without resuming and re-draining the node. scontrol update NodeName=compute-0-1 State=DRAIN Reason='Testing something' # Resume a drained node scontrol update NodeName=compute-0-1 State=RESUME # List usernames with jobs running on localhost only (no jobs = no output) squeue -w localhost --noheader -o %u # Request an interactive job on a specific compute node srun -N1 --mem=200 -w compute-0-1 --pty bash # List configuration data for SLURM # pipe to grep to find a specific setting scontrol show config # Create an ad-hoc, temporary partition # Persists until SLURM config is resynchronized scontrol create PartitionName=omglol Nodes=compute-0-[1-2] Shared=Yes # Schedule a 2 hour reservation on August 4th starting at 16:00 scontrol create reservation starttime=2016-08-04T16:00:00 duration=120 user=root flags=maint,ignore_jobs nodes=ALL # Delete the reservation with the name root_2 (the second reservation created by the user root) scontrol delete ReservationName=root_2 ####### # PBS # ####### # Set update_node_list to 0 in /etc/torque-roll.conf # to prevent automatic updates (by ROCKS) # Node list must be manually maintained in /opt/torque/server_priv/nodes ######## # RAID # ######## # Check on RAID status, resync% cat /proc/mdstat # Get even more general info # including RAID level, # devices sudo mdadm --detail /dev/md0 ########## # NVIDIA # ######### # The SMI in nvidia-smi stands for: System Management Interface # Get all of the lspci output about VGA compatible controllers (sed to print until blank line) lspci -vnn | sed -n '/VGA/,/^$/p' # Print the NVIDIA driver version, once per host (not per GPU) rocks run host compute "nvidia-smi --query-gpu=driver_version --format=csv,noheader|uniq" ############## # TensorFlow # ############## # print TF version python -c 'import tensorflow as tf; print(tf.__version__)' # TF "hello, world" python -c "import tensorflow as tf ; tf.Session(config=tf.ConfigProto(log_device_placement=True))" ######### # numpy # ######### # print config info python -c 'import numpy as np; np.__config__.show()' ####### # SVN # ####### # How do I move an SVN repo? svnadmin dump /awesome/SVN-stuff/operation-marmalade >> operation-marmalade.dump mkdir -p /usr0/SVN/op-marm/ && cd /usr0/SVN/op-marm/ svnadmin create . svnadmin load /usr0/SVN/op-marm/ < /root/operation-marmalade.dump ############### # Diagnostics # ############### # Enable SAR - amd64_u* # /etc/default/systat should contain: ENABLED="true" # View historical RAM usage sar -r # View historical CPU usage sar -u # View historical disk I/O sar -b ################# # Miscellaneous # ################# # Sample pv syntax pv < OMG.txt | sha256sum # Building a machine ## The new file system is mounted at /target ####### # NMH # ####### # Tip: Add /usr/bin/mh to your path # How many messages do I have? /usr/bin/mh/msgchk ## Incorporate new messages in to your inbox /usr/bin/mh/inc ## Read message 8 /usr/bin/mh mhshow 8 (You can also tack -type on to mhshow.) ## Test the format of a message fmttest 7