Simple Things in Linux

I was on irc today and someone on the linux forum asked how to run a file so I thought I would write some simple commands here! Just in case your wondering I advised him to chmod +x then ./filename to run it.

First Some one liners!
cd pathChanges directory, cd
mkdir directorycreates a new directory
pwdTells you the current directory
whoamiTells you what user you are running as
ls -lsList the contents of the current directory (-lsa shows all the details including hidden files, ls -lh lists sizes in human readable form.)
rm filenameremoves a file,rm -r removes recursively (ie desends into directories)
unlink linknameUnlinks a symbolic link
whoshow logged in users
kill processidkills a process

Getting Help

There are many ways of getting help on a linux system, the quickest is to type "command --help" (where command is the name of a linux command. Try "ls --help" it should return a list of command line switches that can be used with ls.

Man Pages are the next line of attack, type "man command" e.g. "man ls" a page of information should appear use the cursers to scroll up and down press q to quit.

Info - info pages are like man pages info command should bring up extended inforamation, info doesnt work for all pacjkages.

If all else fails Searching Goolge or google groups is you best bet. IRC chat rooms (I hang out in quakenet "/server" "/join #linux") can be very useful. Unfortunatly many people will simply tell you to use google, usually because they dont know the answer themselves or its a frequently asked question.

Tab completion

Linux has a really cool feture tab compleation, when you start typing a command or type a few characters then hit the tab key and system will either finish it for you or display a list of alternatives. Try it! This feature is very useful when you dont want to type whole pathnames


Linux Understand wildcards like * and ?. Whats a wildcard you ask, well ls a* would return anyfile that started with a. * Can be used at the start and end and cover any number of characters.

The joy of grep

Grep is an amazingly powerful tool it searchs for strings in text, I find it very useful when dealing with log files, eg "grep named /var/log/messages" will return all the dns server messages from the message log. Alterantive uses are with ls -lsa /etc |grep filename. Quoated strings can be used "grep "some text" /etc/somewhere/somefile".

Changing file permissions

chmod is the program which changes the permission of files. UNIX permissions are quite complex and work from octal values ut I shall try and explain. Permssions which can be set include (W)riteable (R)ead E(x)ecute, these can be set for user, group and world. Permissions are listed as numeric codes 1 is execute, 2 writei, 3 write and executei, 4 read, 5 read and execute, 6 read and write 7 read write and execute.

Ownership chown

In in standard unix permission work in the following ways files have and ownder a group. Permissions to read write and execute can be set seperatly for owner group and world. Users can be memeber of multiple groupsi.SE Linux goes futher in the permissioning.

chown user.{group optional} file changes the owner (and group) on a file. chgrp group file changes the group ownership of a file.


df -h shows the amount of free space on each mounted volume (-h is human readable). df -ih shows the inode (file descriptor useage).

du shows amount of files / space used by each directory, use -s to get a summary of a directory use. du --help shows the associated optiosn there are many a very useful utility for checking your directories out

Symbolic Links

ln -s creates a link to a file

unlink linkname removes symbolic links