The Linux file system is a hierarchical file system organized as a tree, files are said to reside in a directory, directories can contain sub-directories.
Each file has a unique absolute filename, e.g. /usr/bin/ssh, /etc/passwd, and /home/einstein/photoeffect.tex. File names may however also be given as relative file names. Such names are relative to the current working directory.
Print current working directory
$ pwd /home/einstein |
Change directory
cd <directory> |
List files
ls <file(s)> <directory(s)> |
mkdir make directory
Copy file(s). The simplest use, copy file1 to file2, is obtained with
$ cp file1 file2 |
$ cp file1 <file2> directory |
$ cp /home/stud-intro/src/firstprog/* . |
The mv command may also be used in two different ways. If the destination is a directory it moves the file(s)
$ mv file1 <file2>... directory |
$ mv file1 file2 |
Remove one or several files
$ rm file |
Type a file to the terminal
$ cat file1 <file2>... |
A pager that lets you page through the file:
$ more file |
SPACE takes you one screen forward.
"b" takes you backward.
"q" exits more.
Printing is done with the command lpr. To print file:
$ lpr file |
The default (standard) workings of many commands may be changed by supplementing them with an option. The options usually start with a hypen. Options are often used with the ls command. Try the following ones:
$ ls -a
$ ls -F
$ ls -l
The last example gives a long listing
-rw-r--r-- 1 olsson olsson 23254 Aug 26 09:13 linux.mac drwxr-xr-x 2 olsson olsson 4096 Aug 25 14:37 html |
First letter, the kind of file, here ordinary file and directory.
The nine following letters: access rights, r=read, w=write, x=execute. This information appears three times for user, group, and others.
The number of links to this file (don't bother).
Name of the user that owns the file.
Name of the group that owns the file.
File size in bytes.
Date and time for last modification.
File name
Certain files controls how the shell (Chapter 4), emacs (Chapter 5), and other programs behave. The most important of these are located in your home directory, they all start with a period ('.'), and are therefore not displayed when using ls unless the -a option is used:
$ cd $ ls -a . .alias .bash_profile .cshrc .. .bash_history .bashrc .mozilla |
There is also lots of configuration information in the /etc directory. Your personal settings will, however, always take precedence.