lpr
(BSD) and lp
(SysV) for printingps
$ ls / bin/ df.txt initrd/ media/ root/ sys/ var/ boot/ etc/ lib/ mnt/ sbin/ tftpboot/ denyhosts/ export/ linux-images/ opt/ selinux/ tmp/ dev/ home/ lost+found/ proc/ srv/ usr/ $ df Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda1 522028 404048 117980 78% / none 1557628 48 1557580 1% /dev/shm /dev/sda2 10241088 8681048 1560040 85% /usr /dev/sda3 819232 639592 179640 79% /var /dev/sda5 21823584 20355644 1467940 94% /linux-images ... ... netapp:/home/cslab 286703264 129809216 156894048 46% /export/home
$ find /etc -name '*.conf' | less
$ whereis geany geany: /usr/bin/geany /usr/include/geany /usr/share/geany /usr/share/man/man1/geany.1.gz
(See also https://wikiless.tiekoetter.com/wiki/Unix_philosophy)
(See also http://www.faqs.org/docs/artu/ch01s06.html)
# upside down cal cal | tac # number of processes that are associated with me ps aux | grep jchung | wc -l # ?????? wget -q -O - https://www.gutenberg.org/cache/epub/11231/pg11231.txt | sed 's/ /\n/g' | sed 's/[^A-Za-z0-9]*$//g' | sed 's/^[^A-Za-z0-9]*//g' | tr A-Z a-z | sort | uniq -c | sort -rn
env | less
# (or set | less
) SHELL
environment variableenv | grep SHELL
echo $SHELL
$
./etc/profile
~/.profile
(for ksh and bash)~/.bashrc
, ~/.bash_profile
(for bash)~
(the tilde character) is shorthand for $HOME
env | grep HOME
or echo $HOME
~/.bash_profile
for me is the same as /export/home/hawkdom2/jchung/.bash_profile
ls ~
or ls $HOME
are equivalentPS1
shell variablehistory
command lists previously issued commandshistory | grep cat
searches for cat
in the command history~/.bash_history
when user exitsHISTSIZE
and HISTFILESIZE
environment variables, respectively.HISTFILESIZE
is 500HISTSIZE
and HISTFILESIZE
are set in shell configuration fileHISTSIZE
and HISTFILESIZE
to 5000 to increase command line history.~/.bashrc
bash config file.# Display your command history history ... 548 cat .bash_history 549 man bash 550 nano .bashrc 551 source .bashrc !549 # issues 'man bash' command again !man # reissues last command starting w/ 'man' !nan # reissues the 'nano .bashrc' command
alias
to list aliasesalias commandalias='command(s) plus options
'~/.bashrc
).examples/cat
directory under your course directory (cs370
or se370
).man -k
(or the equivalent apropos
command) man -k vim # Search for all man pages containing keyword 'vim' eview (1) - easy Vim, edit a file with Vim and setup for modeless editing evim (1) - easy Vim, edit a file with Vim and setup for modeless editing gvim (1) - Vi IMproved, a programmers text editor gvimdiff (1) - edit two, three or four versions of a file with Vim and show differences gvimtutor (1) - the Vim tutor rgvim (1) - Vi IMproved, a programmers text editor rvim (1) - Vi IMproved, a programmers text editor vim (1) - Vi IMproved, a programmers text editor vimdiff (1) - edit two, three or four versions of a file with Vim and show differences vimtutor (1) - the Vim tutor
cat filename
cat > fileFromCat.txt # The '>' means that keyboard input is 'redirected' to fileFromCat.txt The first line second line third line EOF # EOF is usually entered using Control-D cat fileFromCat.txt The first line second line third line
# output contents of four files to screen $ cat file1 file2 file3 file4 # output to a file, overwriting contents of allFilesTogether $ cat file1 file2 file3 file4 > allFilesTogether # output to a file, appending to contents of allFilesTogether $ cat file1 file2 file3 file4 >> allFilesTogether # using a shell wildcard (*), # cat the contents of all files whose names begin w/ 'file'; files are # concatenated in sorted order, i.e. file1 file2 file3 file4 $ cat file*
nano
editor and then Control-T, Control-Znano
process is suspendedfg
command (fg
= foreground).nano
is brought to the foregroundbg
command (bg
= background).nano
process resumes running in the background.man nano
and Control-Z to suspend it.jobs
command to list the two jobs currently running.nano
with fg %1ps
command and jobsps
command displays process IDs (PIDs)ps aux
or ps fax
show all processes (Linux)ps
options depend on SysV or BSD implementation of ps
ps -ef
displays all processesps -aux
displays all processestop
command shows top processes on system in “real time”./..
shortcuts.
means current directory..
means parent directorymkdir -p dirname
“-p”
option of mkdir
creates entire subdirectory treemkdir -p cs370/examples/cat
rmdir
vs. rm -r dirname
rmdir
is rarely used because it cannot remove non-empty directoriesrm -r dirname
must be used with care.rm -rf
a_directory_namerm -rf
with great care.*
- wildcardls abc*
: list files and directories that begin with “abc”ls *abc*
: list files and directories that contain “abc”[ ]
- subsetls [a-z]*
: list files and directories that begin with a lower case lettermc
: a 2-pane console file manager for power usersls -l
to view permissionschmod
to change permissions of files or directorieschown
to change ownershiproot
(system admin)groups
to see what groups you are inchgrp
to change group ownership of files or directoriessetfacl
, getfacl
to use access control listschmod/chown/chgrp
commandschmod/chown/chgrp/setfacl/getfacl
lpr
and lp
to print from commandlinelpq
and lpstat
to view queued print jobslprm
to remove your own print jobs from print queuesenscript
to convert text to Postscript for prettier outputControl-Shift-C
and Control-Shift-V
, respectively.ssh some_host_name # Example: ssh plato, ssh plato.monmouth.edu
ssh s1100841@plato # or ssh s1100841@plato.monmouth.edu (if off-campus)
ssh-keygen
~/.ssh/id_rsa, ~/.ssh/id_rsa.pub
authorized_keys
on the remote UNIX system that you want to ssh to.ssh-copy-id
~/.ssh/authorized_keys
scp
(secure copy), sftp
(secure ftp) and rsync
.