Skip to content

Latest commit

 

History

History
105 lines (92 loc) · 4.72 KB

UNIX.md

File metadata and controls

105 lines (92 loc) · 4.72 KB

Critical Unix/Linux

Login Customization

You should modify your login script

  • Make ls do ls -F always
  • Make an alias to log into favorite servers
  • Change enviornment variables
    • Don't use your actual $HOME on cluster
    • Add your $HOME/bin to your path
    • Set $PYTHONLIB for your local libraries

Cluster

  • Use nice if you're using a lot of resources
  • Use top or htop to monitor resources
  • Use ^C to kill a job in the foreground
  • Use ^Z to sleep a job in the foreground
  • Use fg to start a sleeping job in the foreground
  • Use bg to start a sleeping job in the background
  • Use ps to show jobs here or ps -lu <username to show all your jobs
  • Use kill -9 <jobid> to kill a job

Quick Reference

Token Function
. your current directory (see pwd)
.. your parent directory
~ your home directory (also $HOME)
^C send interrupt signal
^D send end-of-file character
tab tab-complete names
* wildcard - matches everything
| pipe output from one command to another
> redirect output to file
Command Example Intent
cat cat > f create file f and wait for keyboard (see ^D)
cat f stream contents of file f to STDOUT
cat a b > c concatenate files a and b into c
cd cd d change to relative directory d
cd .. go up one directory
cd /d change to absolute directory d
chmod chmod 644 f change permissions for file f in octal format
chmod u+x f change permissions for f the hard way
cp cp f1 f2 make a copy of file f1 called f2
cut cut -f 2,3 cut columns out of a file
date date print the current date
df df -h . display free space on file system
du du -h ~ display the sizes of your files
git git add f start tracking file f
git commit -m "message" finished edits, ready to upload
git push put changes into repository
git pull retrieve latest documents from repository
git status check on status of repository
grep grep p f print lines with the letter p in file f
gzip gzip f compress file f
gunzip gunzip f.gz uncompress file f.gz
head head f display the first 10 lines of file f
head -2 f display the first 2 lines of file f
history history display the recent commands you typed
htop htop more extensive version of top
kill kill 1023 kill process with id 1023
less less f page through a file
ln ln -s f1 f2 make f2 an alias of f1
ls ls list current directory
ls -F show file types
ls -Fl list with file details
ls -Fla also show invisible files
ls -Flta sort by time instead of name
man man ls read the manual page on ls command
mkdir mkdir d make a directory named d
more more f page through file f (see less)
mv mv foo bar rename file foo as bar
mv foo .. move file foo to parent directory
nano nano use the nano text file editor
pwd pwd print working directory
rm rm f1 f2 remove files f1 and f2
rm -r d remove directory d and all files beneath
rm -rf / destroy your computer
rmdir rmdir d remove directory d
sort sort f sort file f alphabetically by first column
sort -n f sort file f numerically by first column
sort -k 2 f sort file f alphabetically by column 2
tail tail f display the last 10 lines of file f
tail -f f as above and keep displaying if file is open
tar tar -cf ... create a compressed tar-ball (-z to compress)
tar -xf ... decompress a tar-ball (-z if compressed)
time time ... determine how much time a process takes
top top display processes running on your system
touch touch f update file f modification time (create if needed)
wc wc f count the lines, words, and characters in file f
screen screen -S ... start a virtual terminal