UNIX Flashcards
(22 cards)
Read / Write privileges
Three triplets on the left. Then come owner and group. Read, write, execute.
example: drwxrwsr-x
rw-r–r–
110100100
Change permissions
chmod [code] file
chmod +w abc
Change the owner of a file
chown
Change group for a file
chgrp
Get the security details of a file (e.g. who owns it, who is group)
getent
e.g. getent group cs201ta
Read a file and execute the commands you find in that file
source OR .
e.g. source myinstructions OR ./myinstructions
OR
NEWPROG=ls -l
echo $X
Tell us where a program is (e.g. where is the program ls?)
which ls
Tell me what groups I’m a part of
id
Tell me what processes I’m running
ps
Tell me all the environment variables
set
Search path for commands
echo $PATH
Give programs an alias
alias
e.g. alias now=date
alias myls ls
Put commands in a file, then alias, then execute
echo date > dateprog
alias mydate=./dateprog
mydate
» [Tells me the date]
Tell me the present working directory or the past one
echo $PWD
echo $OLDPWD
Random number
echo $RANDOM
Tell me home directory
echo $HOME
Create an environment variable
assignment operator =
TODAY=”Thursday”
echo $TODAY
» Thursday
Tell me my user ID or UID
How to evaluate an expression
expr (e.g. expr 20 + 4)
double parens e.g. echo $((20 + 4))
square brackets e.g. echo $[20 + 4]
Go back n commands
!-n
E.g. !-5
Tell me what is happening in the foreground
fg
Tell me the type of a program
type
e.g. type ls
“Ls is aliased to…”