Linux Commands - for beginners


No need for a Unix background - just have lots of practice and study,
Then you'll begin to understand the basics of Linux.
This page should help you get started, though.
You'll want to buy a good book, too.
"Teach Yourself Linux" perhaps.
But it's here for me as an on-line reference, really.
I hope this page is useful to you

I suppose you could let me know where I've gone wrong - if you have to :-)
Or you could send suggestions ....
You can e-mail me (Gordon WHITE) at: grdnwht@iinet.net.au

Most of these commands will work with most 'flavours' of Linux, I think.


BASIC LINUX COMMANDS:


Command

Action

Starting and Stopping

shutdown -h now

shutdown system (don't re-boot)

shutdown -r 5

shutdown system and re-boot in 5 mins

ctrl-alt-delete

Shutdown system (not fully supported)

halt

Shutdown system (not fully supported)

reboot

Shutdown system (not fully supported)

ctrl-c

aborts executed command

ctrl-u

deletes whole command typed

startx

start X (window system) from shell

shft-ctrl-alt-x

start an xterm session

right click on desktop

display menu (when already in X)

alt-F2

issue single command (from within X)

top

list / kill current processes
(or alt-F2 then ktop from KDE)

Working with Files

cd ..

change directory to one above

cd /usr

change directory to /usr

cd /.

changes to highest level

ls

list files in current directory

ls -alprtCFsS

-a=all files, -l=long, -p=directories, -r=reverse order, -t=time, -A=all except for . & .., -C=columns, -F=filetype, -s=size, -S=by size, -R=recursively

alias ls='ls -FAsS --color'

edit ~/.bashrc to make this change

TAB

word completion

pwd

print working directory

*

wildcard for any number of characters

?

wildcard for single character

[a-m]

wildcard for names beginning with a - m

mkdir name

make a new directory called name

rm name /dir

remove file called name from/dir

rm -rf name

remove entire directory, and all subdirectories - take care with this one!!!

rm dir /name

remove directory called name - directory must be empty including .* files

cp filename /home

copy filename to directory /home

mv filename /home

move filename to directory /home

cat filename

display file called filename

which filename

display pathname to executable filename

more filetoview

display filetoview page by page - using spacebar

|

input re-direction (called pipe)

>

output re-direction

cat filename | more

pipe the display through more for reading

man command

display the manual pages for command

man -k keyword

display man pages containing keyword (q=quit)

info command

display info on command

apropos subject

list man pages for subject/word (q=quit)

head filetoview

display first 10 lines of filetoview

tail -20 filetoview

display last 20 lines of filetoview

tail -f /var/log/messages

display last 10 lines of system log

find / -name file

find file starting from the root directory

find / -name "*file*"

find file with string indicated

grep textstring /dir

list all files containing textstring from /dir

File Systems

mount -t iso9660 /dev/cdrom /mnt/cdrom

mount the CDROM under /cdrom directory

mount -t msdos /dev/fd0 /mnt/floppy

mount DOS floppy disk under floppy directory

umount /mnt/cdrom

u(n)mount the cdrom

usermount

graphical mounting program

du

displays disk usage (-a=all files, -s=space of directories)

df

shows disk free space

e2fsck -av /dev/hda1

check and repair filesystem

fdformat /dev/fd0H1440

format a floppy disk

mkfs -t ext2 -m /dev/fd0H1440 1440

make filesystem on floppy

make zdisk

creates boot disk

tar -cvf archive1.tar /usr/parker

compress /usr/parker into archive1.tar

tar -zxvf archive.tgz

decompress zipped and tarred archive

tar -zxvf archive.tar.gz

as above

tar -cMf /dev/fd0

copy current directory to multiple floppies

Printing

cat file >/dev/lp1

print file (ie to test printing interface)

/etc/rc.d/init.d/lpd start

start print daemon (also 'stop')

lpq

display jobs in print queue

man -t subject | lpr

(postscript) print subject's man page

printtool

X based printer setup interface

User Administration

uname -a

Linux version information

adduser account

create a new user account

password account

give account a new password

su

login temporarily as superuser

exit

revert to ordinary user

passwd

change own password

chown ownerfile

change ownership of file

chmod +x file

make file executable to all users

chmod 764 file

user-all, group-read&write, others-read only
(read=4, write=2, execute=1)

dmesg

display bootup messages

rpm -ihv filename.rpm

install package

to install a "tarball" (.tar)

link to instructions

Directories & Configuration files

/bin

executable files

/dev

device files

/etc

configuration files (ending in 'conf' or 'rc')

/etc/fstab

devices and mountpoints

/etc/motd

message of the day

/etc/rc.d/rc.local

equivalent of autoexec.bat

/etc/HOSTNAME

hostname (including domain)

/etc/inittab

runlevel machine boots into

/etc/X11/XF86Config

X-windows configuration file

/home

users files

/lib

shared library files

/lost&found

files restored after crash

/mnt

where external filesystems are mounted

/opt

programs

/proc

'virtual' system files

/root

administrator's files

/sbin

system administration files

/tmp

temporary files

/usr

X based files and other miscellany

/usr/local

where user programs should be installed

/usr/doc

lots of documentation

/var

changing files (variable) ie spools and queues

~/.xinitrc

defines X-window manager for ~ user

Editing Files

with emacs

ctrl-x ctrl-s

saves file

ctrl-x ctrl-c

exits

with vi(m)

esc i

editing mode

esc : w

saves (writes) file

esc : q

quits

esc : w q

write and quit

esc : q !

quit without saving

..... and?
Print this sheet out and /or save it and reformat it to create a 'cheatsheet' for yourself.

Copyright?

It would be madness to say this was copyrighted, I won't even say it's accurate!
..... but, if you pass it on to someone else, don't claim that YOU created it.
Rather leave the credit on it, that says Gordon WHITE did! Thanks.


Gordon WHITE, 17/10/99
grdnwht@iinet.net.au


Back to the home page