Grazie Margherita

"Il progresso della conoscenza avviene perché noi possiamo basarci sul lavoro dei grandi geni che ci hanno preceduto.".
(Margherita Hack)

LinuxBanner

Linux FileSystem tree


tree -L 1 . ├── bin -> usr/bin ├── boot ├── dev ├── etc ├── home ├── lib -> usr/lib ├── lib64 -> usr/lib64 ├── media ├── mnt ├── opt ├── proc ├── root ├── run ├── sbin -> usr/sbin ├── srv ├── sys ├── tmp ├── usr └── var



Albero filesystem

Subdirectories of the root directory

DirectoryContent
/bin Common programs, shared by the system, the system administrator and the users.
/boot The startup files and the kernel, vmlinuz. In some recent distributions also grub data. Grub is the GRand Unified Boot loader and is an attempt to get rid of the many different boot-loaders we know today.
/dev Contains references to all the CPU peripheral hardware, which are represented as files with special properties.
/etc Most important system configuration files are in /etc, this directory contains data 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!
/lib Library files, includes files for all kinds of programs needed by the system and the users.
/lost+found Every partition has a lost+found in its upper directory. Files that were saved during 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.
/proc A virtual file system containing information about system resources. More information 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.
/root The administrative user's home directory. Mind the difference between /, the root directory and /root, the home directory of the root user.
/sbin Programs for use by the system and the system administrator.
/tmp Temporary space for use by the system, cleaned upon reboot, so don't use this for saving any work!
/usr Programs, libraries, documentation etc. for all user-related programs.
/var Storage for all variable files and temporary files created by users, such as log files, the 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.

Linux FileSystem: types


pwd /home/shady ls -l total 8 drwxrwxr-x. 7 shady shady 117 Jan 21 23:21 database #Directory drwxr-xr-x. 3 shady shady 18 Jan 23 22:13 escapebio #Directory -rw-rw-r--. 1 shady shady 158 Jan 25 19:42 file.txt #Regular File lrwxrwxrwx. 1 shady shady 8 Jan 26 12:47 linkAlFile.txt -> file.txt #Link to Regular File -rw-rw-r--. 1 shady shady 222 Jan 25 19:54 regles.tar.gz #Regular File



Symbol Meaning
- Regular file
d Directory
l Link
c Special file
s Socket
p Named pipe
b Block device

Linux File System and permissions

Had you ever used or heard about the chmod 777 ? If so, my heart is damn bleeding!!!
A Brief intro to permissions. Linux File System store information about: type of data, edge, user, group, others, owner, group, date, name of file.


ls -al drwxrwxrwx 3 shady shady 4096 Sep 22 13:29 . drwxrwxrwx 4 root root 4096 Aug 31 14:56 .. -rw-r--r-- 1 shady shady 512 Sep 22 12:27 array.c -rw-r--r-- 1 shady shady 425 Sep 22 11:45 var.c -rwxr--r-- 1 shady shady 336 Sep 22 11:54 var.sh

First char indicates the type: directory, link, character special file, block special file, - ordinary file
Then we got 3 octet that represents the permission about Read Write and Execute for Users, Group and Others
We talked about "octet". RWX are writeable also as, 111 in octal. 1 stay for True (enabled), 0 stay for False (disabled).


RWX = 111 = 7 (octal)
RW- = 110 = 6 (octal)
R-- = 100 = 4 (octal)
-W- = 010 = 2 (octal)
R-X = 101 = 5 (octal)

Chmod 744 means:
rwx for User
r for group
r for others

Is it really necessary to set 7 (so, Read Write and Execute) for others, too? Others = Guest = anyone!!!
Every user, can do anything into his HOME DIRECTORY. Why extend your privileges to anyone? When you are going to create a new bash script, remember that 744 will be a really fair mod. Security before every other stuff. Do not allow "guests" to modify and save and execute our script.
and, please remember to use "root", only if strictly necessary, not also in order to show the datetime!!!


echo $(date)

Do not try this at home

What do you think would happen if a guest would open a script, would write rm -rf /* at the head of your script and then you, because is your pc, and you are the grandmaster, will open this script as "root"
I'm still shivering, thinking about that!



Linux File System: . and ..


drwx------. 5 shady shady 190 Jan 26 12:47 . #you are here drwxr-xr-x. 43 root root 4096 Jan 26 11:11 .. #before this place, in the tree, there is something owned by "root, group root"


Linux File System: Where am I?


pwd #print working directory /home/shady/escapebio #if we want to go back to "shady" folder we will have to "Change Directory" and go to "before" pointer. cd .. pwd /home/shady/ #our new position #we can use "cd" to enter inside the "next" pointer to folder cd escapebio pwd /home/shady/escapebio #our new position #we can use "cd" to set, directly, the new Directory (with full path) cd /home/shady/escapebio/otherfoler/folder3/folder4 pwd /home/shady/escapebio/otherfoler/folder3/folder4 #our new position


Linux File System: files

I do not want to describe a file! From Cambridge Dictionary: "any of several different types of container used to store papers, letters, and other documents in an ordered way, especially in an office"
Let's go with some useful command:


touch examplefile.txt #will create a file, named exampelfile.txt nano examplefile.txt #you will start the "nano" software in order to edit the file examplefile.txt cp source_path/filename destination_path # the meaning of the word "cp" is "copy"; copy a file from a place to a destination place rm examplefile.txt #it will "remove" (delete) the file from the filesystem. mv source_path/example.txt destination_path/ #will "move" the file example.txt from the source path, to the destination path mv example.txt exampleRenamed.txt #will "rename" the file example.txt in exampleRenamed.txt


Linux File System: SymLinks

A symbolic link (also known as a soft link or symlink) consists of a special type of file that serves as a reference to another file or directory. Unix/Linux like operating systems often uses symbolic links. To make links between files you need to use ln command


ln -s file.txt linkAlFile.txt #we are going to create a "symlink" named linkAlFile.txt to the file file.txt


Linux File System: directory (not folder!!!)

GeOs workbench

Thank's to Microsoft, or maybe to Xerox and Commodore, since the initial version of Windows, the ancient 3.0 people becomes able to own a "personal computer" at home. Microsoft helped to improve the global distribution of computers. Informatic for everyone!!! This OS with a GUI (Graphical user interface) decided to describe a "Directory" as a "Folder" in order to help people to imagine as well and as easy as possible how it works. We'd have to spot to you that directory isn't a folder! But we will leave that kind of metaphor in order to avoid any kind of confusion.


mkdir testdirectory #this command will create a directory rm -R dir1 #will delete the directory named "dir1"


MAN --help or -?

Every function, every command provides help and and/or a manual


man cp #will open the MANUAL of "cp" cp --help #will open a brief reminder to all "cp flags"