OS Tutorial - 1 - Shell
OS Tutorial - 1 - Shell
Disk usage
$ df -h /
File space usage
$ du -sxh ~/
quota – display disk usage and limits
Usage: quota [OPTION]
eg. quota -v
Delete
Vim – dd (delete a line)
2 modes – d10d (delete 10 lines)
Input mode – d$ (delete till end of line)
ESC to back to cmd mode – dG (delete till end of file)
Command mode – x (current char.)
Cursor movement
Paste
– h (left), j (down), k (up),
l (right) – p (paste after)
popd
Bash commands
alias
alias dog=tac
alias c='clear„
alias rm='rm -i'
& ampersand
sleep 20 &
&& double ampersand
cd mydir && ls
Bash commands
|| double vertical bar
echo first || echo second ; echo third
rm file1 && echo It worked! || echo It failed!
# pound sign
\ escaping special characters
echo hello \; world
Bash commands
$ dollar sign: Environment variables
$HOSTNAME, $USER, $UID, $SHELL, and
$HOME.
echo This is the $SHELL shell
echo The userid of $USER is $UID
creating variables
MyVar=555
echo $MyVar
quotes: difference between “ and ‘
How to remove a variable
Bash commands
shell history
repeating the last command !!
repeating other commands !ca
history 10
The bash shell ~/.bash_history.
file commands
Hard, soft (symbolic) link
file <filename>
working with file contents
Look at the contents of text files with head, tail,
cat, tac, more, less and strings.
filesystem hierarchy standard
man hier
the root directory /
/home
ls -d /home/myname/.*
filesystem hierarchy standard
I/O redirection
stdin, stdout, stderr
tr -s filter
tr to 'encrypt' texts with rot13
cat count.txt | tr 'a-z' 'nopqrstuvwxyzabcdefghijklm„