Laborator Linux
Laborator Linux
Lab #1 – Linux filesystem structure, basic commands, getting help in the text environment.
Extra tools(tar, zip, unzip), editors(nano, vim, mcedit), text manipulation(grep, awk, sed, cut)
Page 1 of 8
Linux File System Structure
General overview
Lab #1 – Linux filesystem structure, basic commands, getting help in the text environment.
Extra tools(tar, zip, unzip), editors(nano, vim, mcedit), text manipulation(grep, awk, sed, cut)
Page 2 of 8
Level 1 directories
Directory Content
/bin Common programs, shared by the system, the system administrator and the users.
The startup files and the kernel, vmlinuz. In some recent distributions also grub data.
/boot Grub is the GRand Unified Boot loader and is an attempt to get rid of the many
different boot-loaders we know today.
Contains references to all the CPU peripheral hardware, which are represented as files
/dev
with special properties.
Most important system configuration files are in /etc, this directory contains data
/etc
similar to those in the Control Panel in Windows
/home Home directories of the common users.
/initrd (on some distributions) Information for booting. Do not remove!
Library files, includes files for all kinds of programs needed by the system and the
/lib
users.
Every partition has a lost+found in its upper directory. Files that were saved during
/lost+found
failures are here.
/misc For miscellaneous purposes.
/mnt Standard mount point for external file systems, e.g. a CD-ROM or a digital camera.
/net Standard mount point for entire remote file systems
/opt Typically contains extra and third party software.
A virtual file system containing information about system resources. More information
/proc about the meaning of the files in proc is obtained by entering the command man proc
in a terminal window. The file proc.txt discusses the virtual file system in detail.
The administrative user's home directory. Mind the difference between /, the root
/root
directory and /root, the home directory of the root user.
/sbin Programs for use by the system and the system administrator.
Temporary space for use by the system, cleaned upon reboot, so don't use this for
/tmp
saving any work!
/usr Programs, libraries, documentation etc. for all user-related programs.
Storage for all variable files and temporary files created by users, such as log files, the
/var mail queue, the print spooler area, space for temporary storage of files downloaded
from the Internet, or to keep an image of a CD before burning it.
Lab #1 – Linux filesystem structure, basic commands, getting help in the text environment.
Extra tools(tar, zip, unzip), editors(nano, vim, mcedit), text manipulation(grep, awk, sed, cut)
Page 3 of 8
Directories may vary from distribution to distribution. Actual structure for Oracle Enterprise Linux 6.6.
23 directories, 0 files
Line 1:
- root is the current logged in user on the machine (c006902)
- ~/ is the current working directory
- ls is the command, -lh are the arguments
Line 2 - 8 is the output of the command
Line 9 another prompt. After the ls command has been run, this prompt is waiting for another one.
Advanced version
1 [1015][na01800820@c006902: /home/na01800820]$
1015 is the history number of the command. Instead of ~/ the full path is displayed.
Lab #1 – Linux filesystem structure, basic commands, getting help in the text environment.
Extra tools(tar, zip, unzip), editors(nano, vim, mcedit), text manipulation(grep, awk, sed, cut)
Page 4 of 8
Opening a terminal
From a Windows machine a terminal can be opened via SSH/Telnet with putty. From a linux machines there are dozens
of terminal emulators(Terminator, Guake, Xterm etc).
The shell
What you type in the command line or scripts is executed by a shell which is called an interpretor. The most popular
interpretor is BASH (Bourbone again shell). Other shells are sh (older than bash), tcsh, ksh etc.
To see what shells you have installed on your machine:
Navigation
Where are we?
pwd will print the current working directory
1 [4537][user@testmachine: tmp]$ ls
2 lost+found output rollout.sh sudoers
Paths
Relative paths are paths from the current point forward. Full paths are from the root directory(/) forward. Example:
The current working directory is /tmp/test which contains the test2 directory which contains a text file.
1 [4552][user@testsystem: test]$ ls
2 test2
More paths:
Lab #1 – Linux filesystem structure, basic commands, getting help in the text environment.
Extra tools(tar, zip, unzip), editors(nano, vim, mcedit), text manipulation(grep, awk, sed, cut)
Page 5 of 8
~ Is the shortcut for the home directory for the current logged in user. Example /home/student/Downloads can be used as
~/Downloads
. (dot) is the current working directory. We will talk later why is this useful.
.. (dotdot) is the previous directory(parent directory).
1 [4559][user@testsystem: test]$ cd ~/
2 [4560][user@testsystem: /nfs/home/user]$ pwd
3 /nfs/home/user
4 [4561][user@testsystem: /nfs/home/user]$ cd /tmp/test/test2
5 [4562][user@testsystem: test2]$ pwd
6 /tmp/test/test2
7 [4563][user@testsystem: test2]$ cd ..
8 [4564][user@testsystem: test]$ pwd
9 /tmp/test
10 [4565][user@testsystem: test]$ cd
11 [4566][user@testsystem: /nfs/home/user]$ pwd
12 /nfs/home/user
Basic commands
Linux ignores file extensions. So basicaly you can have a text file that ends in .txt.
file – is the command to find out what is actually that file.
Lab #1 – Linux filesystem structure, basic commands, getting help in the text environment.
Extra tools(tar, zip, unzip), editors(nano, vim, mcedit), text manipulation(grep, awk, sed, cut)
Page 6 of 8
Files and folders
:>test.exe – can be used to create an empty file. We will see what :> actually means later.
mkdir – is used to create a directory
cp – is used to copy a file/folder
mv – is used to move a file/folder
rm – is used to delete a file/folder
rmdir – is used to delete a folder
Manual pages
To read the manual page for a command type
man <command>
Commands contain a lot of parameters which actually help you achive what you want on the screen more easly. It's
always advised to read at least once the manual page for all commands you use and test what the effect of diferent
arguments and parameters.
In theory all commands have a manual page, but it is the possibility of some 3rd party proprietary(non-free) software are
packaged non-LSB(Linux Standard Base) compliant.
File editors
Most popular file editors are vim, nano and mcedit.
Text manipulation
In linux, you have a powerful set of tools for text manipulations. This is very handy, among other uses, in parsing logs
and generating custom outputs.
grep – print lines matching a pattern
sed - stream editor for filtering and transforming text
awk - pattern scanning and processing language
cut - remove sections from each line of files
tr - translate or delete characters
Appendix
pwd
ls
cd
file
cat
mkdir
cp
mv
rm
rmdir
man
grep
sed
awk
cut
Lab #1 – Linux filesystem structure, basic commands, getting help in the text environment.
Extra tools(tar, zip, unzip), editors(nano, vim, mcedit), text manipulation(grep, awk, sed, cut)
Page 7 of 8
tr
cat
ftp://download.srv.ro/pub/centos/6/isos/x86_64/
https://www.virtualbox.org/
Lab #1 – Linux filesystem structure, basic commands, getting help in the text environment.
Extra tools(tar, zip, unzip), editors(nano, vim, mcedit), text manipulation(grep, awk, sed, cut)
Page 8 of 8