linux admin course notes

I have just finished a rewarding 4 day course at OpenAdvantage on linux admin, very presented and run by Paul Cooper. I got a lot out of the course, but there was a wide range of attendees, from people with (literally) decades of unix experience to me, a microsoft convert making early steps in the command line environment. The course was based on the linuxIT course , for people working towards the linux professional institute exams (which I’m not taking!)

Overall, an excellent course. What I want to take away is a crib sheet of linux commands and notes I can sync into my address book, so that when I next need to run stuff on the command line its easy to hand. So here goes… Please note that these are my crib notes, not a definative linux command line crib sheet!

BASIC COMMAND LINE COMMANDS

echo “test” returns the text

CREDIT=300
echo $CREDIT returns the variable

ls -hl lists files in detail in human readable format
pwd tells you where you are in the directory structure

env shows the environment you are working in

ls -l >errors.txt redirects the output to errors.txt

set shows all variables
| Pipe symbol glues the lot together

ls f* gives all files starting with f
ls f???s.* gives all files but only with the right number of characters
ls [a-e]*.* for a range
ls my documents for files with a space in the name

SHORTCUTS

cntrol shift c and control shift v are copy and paste

tab gives tab completion of a predictable string
up arrowauto completes from the history of command lines submitted

home and end keys more up and down the line
man is the manual command for HELP!
eg
man ls

q to quit

alias ll=ls -l is a shortcut command

cd /media is absolute command to the media

FINDING FILES

find -name “f*.txt”

or

locate / “f*.txt”

REMOVE FILES

rmdir for directories
rm -r music removes the directory and all contents

COPY FILES

cp fil* my documents to copy

MOVE FILES

mv is move file

FILES SYSTEMS
ext2 is the linux old equivilant of fat32, a basic file format for linux
ext3 joural based file system – best to use

swap file partition should be double actual physical memory

lspci lists the hardware

RUNNING AS ROOT

sudo runs a single command as root
su is switch user eg
su – root

FORMAT DISKS

sudo fdisk /dev/sda runs the fdisk command

df tool for mounted and
du -h /usr as an example of finding file sizes

PERMISSIONS
user u
group g
other o

read r or 4
write w or 2
execute x or 1

character 1 is file info, 1-3 is user,4-6 is group,7-9 other

chmod u+x files.txt gives execute permision to users

PROCESSES

pstree -p shows the runningprocesses
ps ax shows all process for all users

kill pid number kills the process
or
kill -9 pid number

top gives the running processes

nohup runs outside the session

TEXT EDITOR

at is a basic text editor
control D stops it

head -5 hello.txt gives you the last 5 lines of hello.txt

grep term filename > results.txt

VI or VIM is a good embedded text editor

q! to quit

esc to go back to command line
x to save and escape

SSH

at command line you can ssh to any url

STOP AND START PROCESES
eg
sudo /etc/init.d/ssh stop

w
whoami tells you who is on a machine

SECURECOPY

scp root@ the address :whoteist.txt whitelist.txt is a secure copy

TIMING

crontab -l to list
crontab -e to edit

eg
45 14 * * * /bin/touch /home/demo/results.txt
will touch the results file at 14:45 every day

NETWORK

ifconfig gives you your network information, your IP address etc


I hope this is enough of a memory dump for future reference.  Thanks Paul for a very useful course