Dr. Mark Humphrys

School of Computing. Dublin City University.

Online coding site: Ancient Brain

coders   JavaScript worlds

Search:

Free AI exercises


Introduction to UNIX / Linux (More)



Some Commands to get started

Explore commands and options by typing "man (command)"
e.g. "man ps"

clear                   Clear screen
  


Files


ls                      List files
ls -a                   Show "hidden" files (begin with ".")
ls -l                   Detailed
ls -alR                 Recursive

cat (file)              Type file out in command-line window

more (file)             Type file, pause for each screenful
                        enter for new line, space for next page, q to quit


Manipulating files

Human can use GUI file manager. Programs can do anything a human can do, with these commands. Human sometimes types these commands too.

cp                      Copy files
mv                      Move / Rename files
rm                      Remove files
mkdir                   Make directory
rmdir                   Remove directory
  
See tutorials on manipulating files with cp, mv, rm, etc.


Detach program (&)


(prog) &                Launch a process detached 
                         from command-line (e.g. windowed)
(prog)                  Command-line frozen until prog exits.

           
eog file.jpg &		Launch image viewer Eye of GNOME on file
gedit file &            Launch gedit editor on this filename 
    



Web browsers


google-chrome &              Launch Web browser from command-line
google-chrome "URL" &




sort


sort 		Sort alphabetically (pipe some stream into sort)
sort -n		Sort numerically
sort -r		Reverse sort 

sort by 5th column:
sort -k 5

old syntax to sort 5th column:
sort +4     

  

grep


grep      Search for a string in a file or files

grep (string) (file)
grep (string) *html 

grep -i (string) (file)  Ignore case
grep -v (string) (file)  Return lines that do NOT match 
  

find

find      Find files by type/date/name, in this dir or below 

find -type d       Find all dirs 
find -mtime -1     Find files modified today



Printing

These commands exist. Not sure if they work for you:

lp (file)               Print
lpr (file)              Print (on some systems)
lp -Pl128 (file)        Print on printer l128 (L128)

lpq                     See print queue
lprm                    Remove job from queue
  

cal


cal 8 1752              Calendar for Aug 1752
cal 9 1752              Calendar for Sept 1752
cal 10 1752             Calendar for Oct 1752

  

which


which (prog)            
 what runs if "prog" is typed
 may return nothing if prog is an alias

which ls


type (prog)
 returns path of prog
 or else shows what prog is alias for

type h
type history


whereis (prog)		Where the binary, source, manual pages are for this prog
whereis perl
 




Misc


w                       Who is logged in
           (see this when you ssh student.computing.dcu.ie)
 
(command) ; (command)   Multiple commands on same line




wget

Command-line HTTP client.


wget -q -O - URL      					  	Download URL, quiet, output to command-line
 
wget -q -O - URL > file.htm 					Output to file

wget -q -O file.htm  URL  					Output to file

wget -q -O - http://site/file.jpg  > file.jpg 		Output JPEG to file (output JPEG to command-line won't work)

wget -q -O file.jpg  http://site/file.jpg   		Output JPEG to file 


 see more on wget





wget appears in this hacking scene from the movie The Social Network (2010).
Perhaps the most realistic hacking scene in the history of movies.



ancientbrain.com      w2mind.org      humphrysfamilytree.com

On the Internet since 1987.      New 250 G VPS server.

Note: Links on this site to user-generated content like Wikipedia are highlighted in red as possibly unreliable. My view is that such links are highly useful but flawed.