Elf Qrin's Lair

UNIX Quick Reference

telnet [host]                       Connect to host (25 (SMTP), 109/110 (POP3), 21 (FTP), 20 (FTP data) )
ssh [host]                          Secure telnet to host
rlogin -l [username]                Connect to host (no passwd necessary if in .rhost (host username) )
ftp    -i                           File transfer with host (-i (don't promt when using mget), hash (status))
ftptool                             X-window based FTP prgram
xhost +/- hostname                  Allow host to open X-Window on local machine  (setenv DISPLAY locmach:0.0)
talk [username@host]                Talk to username
write [username]                    Write directly to username, you must be on the same machine
mesg -yes / -no                     Enable or disable receiving of messages
logout, bye                         Disconnect from host
passwd, yppasswd , chfn, chsh       Change local or NIS password information
slirp                               Slirp (conf: .slirprc) (options: -P -b 9600 "asyncmap FFFFFFFF" "mtu 1500"
                                    "mru 1500" compress ppp-exit debug papcrypt (save encrypted passwd in file
pppd                                PPP (use chat -v to connect) (options: 9600 locIP:remIP asyncmap FFFFFFFF
                                    crtscts mru 1500)
aspppd                              To automatically build a ppp-connection if needed
httpd                               HTTP-Server (confiles: httpd.conf, srm.conf, access.conf)
exit                                Log out from ssh, telnet, rlogin
quit                                Log out from ftp

File transfer and Mail:
mailx                               Read mails
mailx -s [subject] [user]           Send mail to user  ("." (finish)  q (quit), x (quit without changing),
                                    n (next), d (delete), r (reply), h (display mails) )
telnet host 25                      SMTP (helo (authorize), mail from: (snd address), rcpt to: (rec address),
                                    data (mail body), "." (finish) )
telnet host 110 (or 109)            POP3 (user [username], pass [password], uidl (listmails), retr [n]
                                    (retrive message n), dele [n] (delete message n), quit)
get                                 Get file from ftp-host
mget                                Get multiple files from ftp-host (can use wild char)
put                                 Copy file to ftp-host

Connect info:
who                                 Who is connected
w                                   Similar to who just displays more info, like processes and load
finger [-l @host]                   Display info about logged on users
finger [user]                       Display info about user
whois [-h host name]                Scans for a name or handle
rusers                              Scans the whole remote network for connected users
whoami                              Display the effective current username
id                                  List user & group ids
last -n [num]                       List the num last users who have logged in, by user or terminal

nslookup                            Query domain name servers interactively
route                               Routing (add host/net target gateway 0)
netstat -nr                         Routing table. Show network status
ifconfig [device]                   Show the stats of network device, or all devices: -a
ifconfig lo0:1 up    Enables a previously added route (very important!)
                                    Put this at the end of the file: /etc/init.d/sysid.net
traceroute [hostname]               Tracing IP packet from this host to hostname

jobs                                List jobs running in the background
ps                                  List current processes (ps -aef | grep $USER)
CTRL + Z                            Suspend
kill [pid] / CTRL + C               Kill a job (use pid returned by ps; -9 exit immediately)
bg                                  Send to background. Returns num to use when calling fg
fg [num]                            Send to foreground
comm &                              Execute command in background
nohup comm &                        Continue execution of command even when terminal is down
CTRL + U                          New commandline
CTRL + S                          Stop output
CTRL + Q                          Continue

pwd                                 Display the pathname of the current working directory
cd [dirname]                        Change to directory dirname (cd without dirname wil go to your home
                                    directory, cd .. moves one directory up, cd ~username moves you to
                                    username's homedir)
mkdir                               Make directory
rm, rmdir [dirname]                 Remove (unlink) files or directories
dircmp                              Compare directories
ln -s [realpath alias]              Make symbolic links to files
df -bk                              Report free disk space on file systems
disktool -u [dir]                   Display disk usage o directory
fsck                                File system consistency check and interactive repair

ls -l                               List files  (-a (list invisible files), -d (don't list contents of a folder),
                                    -R (recursively subdir listing) )
mv [old new]                        Move or rename a file or directory  (no -r needed)
cp [-r file]                        Copy file  (-r (copy directory) )
tar -cf - [source] | (cd [target]; tar -xfvp-;) Fast copying using tar (p: keep  permissions, v: verbose)
cd [source]; tar -cf - . | (cd [target]; tar -xfvBp - ) Another possibility (p: keep  permissions)
rm [-rf file]                       Remove file  (-f (don't prompt user), -r (remove directory) )
perl -p -i.old -e 's/oldstring/newstrin/g' *.txt    Search and replace of a string in multiple files
chmod [o+r file]                    Change access for file (-R recursively)  {u=rw,og+r,a-w}
chmod [ugo]                         4=r 6=rw 5=rx 7=rwx                      {644=rw_r__r__}
umask [x]                           Without param=disp with=set              {27=rwxr_x__  67=rwx______}
chown [user:group file]             Change owner of file
chgrp [group]                       Change the group ownership of a file
more [file]                         Type file  (b=back, v=VI, /[string] (search for string) )
cat [file1 file2] > targetfile      Concatenate files
catman                              Create the cat files for the manual
split -b [bytes file]               Split file to packets with size bytes
csplit                              Split a file with respect to a given context
dd                                  Convert and copy files with various data formats
find [path criteria]                Searches for files  (-name ['name']  -mtime [n] (changed n days ago),
                                    -atime [n] (last read n days ago), -group [gname])
volcheck                            Mount floppy, content will become visible in /floppy/floppy0
eject                               After leaving the /floppy/floppy0 directory ejetct the disk
fdformat                            Format a floppy for UNIX
fddisk -fmt -f /dev/rfd0a           Format a floppy on trevano
mformat a:                          Format a floppy for MS-DOS
mcopy [unixfile a:dosfile]          Copy to a dos disk or the other way round
mdel [a:dosfile]                    Delete a MS-DOS file
dos2unix [file]                     Convert text file from MS-DOS format to Unix/ISO format
unix2dos [file]                     Convert text file from Unix-ISO format to MS-DOS format
mcopy [unixfile a:dosfile]          Copy to a dos disk (better use the directory /floppy/floppy0)
xhfs                                Use Mac disks (HFS file system)
hfs                                 Use Mac disks (mount /vol/dev/aliases/floppy0, copyin, copyout, dir) 
perl -p -i.old -e 's/\r/\n/g' [files] Replaces returns with linefeeds (convert from mac to unix or dos to unix)
diff [file1] [file2]                Compares two files and display line-by-line differences
diff3                               Display line-by-line differences between 3 files
diffmk                              Mark differences between versions of a troff input file
touch [filename]                    Update the access and modification times of a file
mkfile                              Create a file (e.g. for swap space)

make                                Build source code. Maintain, update, and regenerate programs and files
cc                                  C Compiler
gcc [file.c]                        C Compiler
g++ [file.C]                        C++ Compiler
cxx                                 C++ Compiler
adb, dbx                            Debugger
dbxtool                             SunView interface for the dbx source-level debugger
cxref                               Generate a C program cross-reference
cflow                               Generate a flow graph for a C program
javac [file.java]                   JAVA-Compiler
pc                                  Pascal compiler

gzip [file]                         Compress file (.gz)
gunzip [file]                       Decompress file (.gz)
tar -cvf [targetfile.tar] [source]  Create archive (.tar) from multiple source files
tar -xvf [file]                     Unpack archive (.tar)
tar -tvf [file]                     List archive (.tar) doesn't expand the archive
compress [file]                     Compress file (.Z)
uncompress [file]                   Decompress file (.Z)
zcat [file]                         Display expanded contents

lpr [-P[printer] file]              Print file on printer  (-K2 (double sided), -#2 (two copies) )
lp [-d[printer] file]               Print file on printer  (-K2 (double sided), -n2 (two copies) )
lp cancel                           Cancel requests to a printer
lpc                                 Line printer control program
lprm                                Remove jobs from the printer queue
mapge -[num] -h [file] | lpr        Print num pages on one page with header (-h option)
nenscript [-p- file]                Translate file to Postscript (stdout)
nenscript [-p- file] | lpr          Translate file to PS and print it
lpq                                 List queue
lprm [job-ID]                       Remove job from queue
lpstat -a                           List all available printers
lptest                              Generate lineprinter ripple pattern
psp1 [file] / psp2 [file]           Print text (user defined script)
a2ps                                Convert text files to ps (nicely formatted)

Other Commands:
man [comm]                          Get info about command (-k keyword)
apropos [expr]                      Get info about related commands
where [comm]                        Show path of command
grep, egrep, fgrep [expr]           Filters out lines containing expr (-i (not case sensitive), -c (count
                                    only), -v (inverse) )
cut                                 Remove selected fields from each line of a file
cut [-c Num-Num]                    Cuts lists
[comm] > [file]                     Write output of command to file
[comm] >> [file]                    Append output of command to file
[comm] < [file]                     Content of file => input of command
[comm1] | [comm2]                   Output of command1 => input of command2
lynx                                Text based version of netscape (g (go), q (quit), left (back), enter
                                    (follow link), Search: http://www.google.com)
alias [alias comm]                  Define alias for long commands
stty                                Set or alter the options for a terminal
stty erase \^\?                     Set erase key to backspace (or other terminal settings)
h                                   Display history (on trevano only)
echo [$var]                         Print value of var or expr        {HOME, PATH, SHELL, USER, PRINTER, DISPLAY}
setenv [var val]                    Set var to val                    {HOME, PATH, SHELL, USER, PRINTER, DISPLAY}
CTRL + ARROW                        Switch workspace
xsetroot -solid blue                Set background
xinit                               Initialize X-Server (use strtx to start X-Server)
rup [hostname]                      Status of host
boot sd(0,6,2)                      Boot from CD-ROM (check with probe-scsi first)
halt / fasthalt                     Shut down (root only)
boot                                Reboot the system
halt                                Halt the system
fastboot                            Reboot the system without checking the disks
fasthalt                            Halt the system without checking the disks
su                                  Become super user (or any other user)
starting NFS                        /usr/lib/nfs start all apps there
perl -p -i.old -e 's/oldstring/newstrin/g' *.txt   Search and replace of a string in
                                    multiple files
clear                               Clear screen
nslookup                            Resolve domain names (server [dnsserver] (specify damain e.g: ElfQrin.com)
adduser                   procedure for adding new users
arch                      display the architecture of the current host
at, batch                 execute a command or script at a specified time
atq                       display the queue of jobs to be run at specified times
atrm                      remove jobs spooled by at or batch
automount                 automatically mount NFS file systems
awk                       pattern scanning and processing language
banner                    display a string in large letters
bar                       create tape archives, and add or extract files
basename, dirname         display portions of pathnames and filenames
biff                      give notice of incoming mail messages
cal                       display a calendar
calendar                  a simple reminder service
cb                        a simple C program beautifier
click                     enable or disable the keyboard's keystroke click
clock                     display the time in an icon or window
cmdtool                   run a shell (or program) using the SunView text facility
cmp                       perform a byte-by-byte comparison of two files
colrm                     remove characters from specified columns within each line
config                    build system configuration files
cpio                      copy file archives in and out
crontab                   install, edit, remove or list a user's crontab file
ctrace                    generate a C program execution trace
date                      display or set the date
dc                        desk calculator
devinfo                   print out system device information
dkinfo                    report information about a disk's geometry and partitioning
dname                     print RFS domain and network names
domainname                set or display name of the current NIS domain
dos                       SunView window for IBM PC/AT applications
du                        display the number of disk blocks used per directory or file
dump, rdump               incremental file system dump
dumpfs                    dump file system information
edquota                   edit user quotas
eeprom                    EEPROM display and load utility
enablenumlock, disablenumlock         enable or disable the numlock key
env                       obtain or alter environment variables for command execution
eqn, neqn, checkeq        typeset mathematics
error                     categorize compiler error messages, insert at responsible source file lines
expand, unexpand          expand TAB characters to SPACE characters, and vice versa
exportfs                  export and unexport directories to NFS clients
exports, xtab             directories to export to NFS clients
expr                      evaluate arguments as a logical, arithmetic, or string expression
extract_patch             extract and execute patch files from installation tapes
extract_unbundled         extract and execute unbundled-product installation scripts
factor, primes            factor a number, generate large primes
file                      determine the type of a file by examining its contents
fmt, fmt_mail             simple text and mail-message formatters
fold                      fold long lines for display on an output device of a given width
fonftlip                  create Sun386i-style vfont file
fontedit                  a vfont screen-font editor
format                    disk partitioning and maintenance utility
fortune                   print a random, hopefully interesting, adage
from                      display the sender and date of newly-arrived mail messages
fstab, mtab               static filesystem mounting table, mounted filesystems table
f77                       running Fortran on Suns
gfxtool                   run graphics programs in a SunView window
groups                    display a user's group memberships
gterm                     virtual graphics terminal for the SunView environment
gxtest                    stand alone test for the Sun video graphics board
head                      display first few lines of specified files
hostid                    print the numeric identifier of the current host
hostname                  set or print name of current host system
hosts                     host name data base
hosts.equiv, .rhosts          trusted remote hosts and users
iconedit                  create and edit images for SunView icons, cursors and panel items
id                        print the user name and ID, and group name and ID
imtool                    image display server for the SunView environment
indent                    indent and format a C program source file
iostat                    report I/O statistics
join                      relational database operator
lastcomm                  show the last commands executed, in reverse order
ld, ld.so                 link editor, dynamic link editor
ldd                       list dynamic dependencies
leave                     remind you when you have to leave
lex                       lexical analysis program generator
logname                   get the name by which you logged in
look                      find words in the system dictionary or lines in a sorted list
mach                      display the processor type of the current host
mail, Mail                read or send mail messages
mailtool                  SunView interface for the mail program
mkfs                      construct a file system
mkproto                   construct a prototype file system
mount, umount             mount and unmount file systems
mt                        magnetic tape control
nawk                      pattern scanning and processing language
newaliases                rebuild the data base for the mail aliases file
newfs                     create a new file system
nice                      run a command at low priority
nl                        line numbering filter
nroff                     format documents for display or line-printer
od                        octal, decimal, hexadecimal, and ascii dump
pagesize                  display the size of a page of memory
paste                     join corresponding lines of several files, or subsequent lines of one file
perfmeter                 display system performance values in a meter or strip chart
ping                      send ICMP ECHO_REQUEST packets to network hosts
pr                        prepare file    for printing, perhaps in multiple columns
printenv                  display environment variables currently set
pstat                     print system facts
quota                     display a user's disk quota and usage
rc, rc.boot, rc.local         command scripts for auto-reboot and daemons
rcp                       remote file copy
rdate                     set system date from a remote host
rdist                     remote file distribution program
reboot                    restart the operating system
renice                    alter nice value of running processes
repquota                  summarize quotas for a file system
restore, rrestore         incremental file system restore
rev                       reverse the order of characters in each line
rsh                       remote shell
ruptime                   show host status of local machines
script                    make typescript of a terminal session
sdiff                     contrast two text files by displaying them side-by-side
sed                       stream editor
sh                        shell, the standard UNIX system command interpreter and command-level language
shelltool                 run a shell (or other program) in a SunView terminal window
showmount                 show all remote mounts
shutdown                  close down the system at a given time
sleep                     suspend execution for a specified interval
sort                      sort and collate lines
spell, hashmake, spellin, hashcheck       report spelling errors
spline                    interpolate smooth curve
strings                   find printable strings in an object file or binary
strip                     remove symbols and relocation bits from an object file
sundiag                   system diagnostics
suninstall                install and upgrade the SunOS operating system
sunview                   the SunView window environment
swapon                    specify additional device for paging and swapping
symorder                  rearrange a list of symbols
sync                      update the super block; force changed blocks to the disk
tabs                      set tab stops on a terminal
tail                      display the last part of a file
tbl                       format tables for nroff or troff
tcopy                     copy a magnetic tape
tee                       replicate the standard output
tektool                   SunView Tektronix 4014 terminal-emulator window
test                      return true or false according to a conditional expression
textedit                  SunView window- and mouse-based text editor
time                      time a command
toolplaces                display current SunView window locations, sizes, and other attributes
tput                      initialize a terminal or query the terminfo database
tr                        translate characters
trace                     trace system calls and signals
traffic                   SunView program to display Ethernet traffic
troff                     typeset or format documents
tset, reset               establish or restore terminal characteristics
tsort                     topological sort
tty                       display the name of the terminal
tunefs                    tune up an existing file system
uniq                      remove or report adjacent duplicate lines
units                     conversion program
unmount, umount           remove a file system
uptime                    show how long the system has been up
users                     display a compact list of users logged in
vacation                  reply to mail automatically
vi, view, vedit           visual display editor based on ex   
vipw                      edit the password file
vmstat                    report virtual memory statistics
wall                      write to all users logged in
wc                        display a count of lines, words and characters
whatis                    display a one-line summary about a keyword
whereis                   locate the binary, source, and manual page files for a command
which                     locate a command; display its pathname or alias
yes                       be repetitively affirmative

csh is a shell (command interpreter) with a C-like syntax and advanced interactive features
csh, %, @, alias, bg, break, breaksw, case, continue, default, dirs, else, end, endif, endsw, eval,
exec, exit, fg, foreach, glob, goto, hashstat, history, if, jobs, label, limit, logout, notify,
onintr, popd, pushd, rehash, repeat, set, setenv, shift, source, stop, suspend, switch, then,
umask, unalias, unhash, unlimit, unset, unsetenv, while

Important directories and files:
~/.fvmrc                            Window mangager configuration (FVWM)
~/.dtwmrc                           Window mangager configuration (DTWM)
~/.dt/*                             (errorlog, startlog, icons, types (setting of launch pad), other DTWM
~/.tcshrc                           TC-Shell settings
~/.cshrc                            C-Shell settings
~/.login                            Login script  (for desktop login only, executed once)
~/.rhosts                           Remote hosts file
~/.httpusers                        Alowed users for secret pages
~/.pap-secrets                      PAP secrets for slirp
~/.slirprc ~/.ppprc                 Slirp and ppp config files
~/public_html                       Home Page directory
/usr/bin                            Applications
/usr/local/bin                      More applications
/opt/gnu/bin                        Gnu stuff like g++, gcc, gzip and more
/usr/sbin                           System tools
/usr/share/man                      Manual files    
/dev                                Devices like ttya (serial port), audio and disk drives
/vol                                Automounted volumes
/etc                                (rc2 (things to do at startup), rc2.d (startup e.g. S72inetsvc (routing)
                                    passwd, shadow (passwords), resolve.conf (DNS IP addresses), hosts,
                                    ftpusers (users who can't access ftp), shells (users and their shell
                                    important for ftp), services (port numer and its service), nsswitch.conf (in
                                    colum hosts we have to write dns to use dns resolving), ppp/ (pap-secrets and
                                    other ppp settings), nodename, hostname.[interfacename] (hostname associated
                                    with this interface e.g. le0), fstab (mounting table), ssh_* (ssh stuff) )
/usr/var/log                        Home Page Log on SUN
/usr/local/WWW/logs                 Home Page Log on OSF1
/var/adm                            messages (Messages from applications and startup process (for debugging
                                    purposes), sulog)
/var/spool/mail                     Mail (on SUN: /var/mail)
/usr/local/WWW                      WWW-directory (e.g. settings and CGI)
/usr/local/etc/httpd                WWW-directory on gummibaum
/usr/dt/config/C/*                  Default desktop settings (Xresources (Configuration file for the Login
                                    Manager), sys.dtwmrc (default windowmangager configuration), and others)
/soft/public/X11/lib/fvwm/system.fvwmrc        System fvwmrc file
/etc/issue.net                       Welcome message (before login in)

<ESC>                               Command mode
i                                   Insert
I                                   Insert at beginning of a line
a                                   Insert after
A                                   Insert at the end of the line
o                                   Insert a line below
O                                   Insert a line above
J                                   Connect this and the next line
r                                   Change char
R                                   Overwrite
x                                   Delete char
dd                                  Delete line
D                                   Delete rest of line
h / l                               Move left / right
j / k                               Move down / up
w,b,e                               Move cursor one word
H                                   Home
L                                   End
M                                   Middle
G                                   Go to bottom
p                                   Undo
ctrl + f                            Page down
ctrl + b                            Page up
:/[string]                          Search for string
:?[string]                          Search backwards
:[n]                                Goto line n
:w                                  Save
:q                                  Exit
:x                                  Save & exit

Navigation inside more, man...

SPACE                               Moves one page down
B                                   Moves one page up
ENTER                               Moves one line down
Q                                   Quit

X-Windows Progs:
xterm / dtterm                      Terminal
xmailtool / mailtool                Mail
emacs / textedit                    Word processor
xcalc                               Calculator
xv                                  Graphic viewer and converter
xlock                               Lock up
xset                                X-Win settings

alias ls        ls -l               List in long format
alias rm        rm -rf              Remove files and directories without prompting user
alias cp        cp -r               Copy files and directories
alias df        df -bk              Display free space and used space in bytes
alias ps    ps -aef | grep $USER    List all jobs of user
alias txt2ps    nenscript -p-       Translate text to PostScript (stdout)
alias psp1 /~/Script/psprint1       Print text on dali
alias psp2 /~/Script/psprint2       Print text on ps2

starts with: #!/bin/sh, contains command lines, must have x-permission, start with ./Scriptname, *=any string (except .), ?=any char, [a-d]=any char from a to d (lower case), be carefull with special chars &=\&, to execute
at a specific time use: at hh:mm +[minutes] minutes < Scriptname, to divert to nirvana stout: >&- or stin: <&-

Standard: <+>="AND"  <space>="OR"
Advanced: AND  OR  NEAR  URL  ()   *    (e.g: apple* AND ((quicktime OR video) NEAR 3.0) )


Issued on Elf Qrin's Hacking Lab
Legal notices and disclaimer