4. Exploring the system
To explore the system we use these steps:
- Use
cdto go to a directory. - List the directory contents with
ls -l. - If you see an interesting file, determine its contents with the
command
file. - If it looks like it might be text, try viewing it with
less.
Let's try some of these:
-
Go to
/binand list its content:cd /binls -lls -l b*ls -l bzless -
Check the type of some files and their contents:
file bzlessThe file
bzlessis a symbolic link, a kind of shortcut, or alias, or a reference to another file. There are also hard links which we will see later.ls -l bzmorefile bzmoreThe file
bzmoreis a shell script and actually a text file, so we can read its content:less bzmorePress [Space] a couple of times, and then quit with
q.Shell scripts are like programs and contain Linux commands.
The command
lessdisplays the contents of a text file page-by-page.Note: The command
lessis an improved replacement of an earlier Unix command that was calledmore. So, sometimes it is said that:lessismore. Or:lessis more or lessmore. -
Let's check another file:
ls -lh bashfile bashThe file
bashis an executable program, and a binary (non-text) file. Let's try to read its content:less bashExit with
q.As you see, text files have a content that is readable by humans, non-text files (or binary files) have a content that is not readable by humans (but it may be read and interpreted by some programs).
-
Let's check
/etc:file /etcls -l /etc/passwdfile /etc/passwdIt is plain text. Let's check its content:
less /etc/passwdThis file contains the accounts of the system.
The files on
/etcare usually configuration files, and almost all of them are text files (readable and writable by humans). -
In contrast, the files on
/binare programs or commands and they are mostly binary files or shell scripts. The same goes for/sbin,/usr/bin,/usr/sbin,/usr/local/bin, etc.ls /sbinls /usr/binls /usr/sbinls /usr/local/bin -
Some other important directories are:
ls /bootls /boot/grubContains the Linux kernel, initial RAM disk image, the boot loader, etc.
ls /devfile /dev/ttyfile /dev/pts/1Contains device nodes.
ls /homeContains home directories of the users.
ls /libls /usr/libContains shared libraries.
ls /procless /proc/cpuinfoThis is a special directory that exposes the settings and the state of the kernel itself.
ls /varls /var/logContains data that are likely to change frequently (like log files).
ls /tmpTemporary data which might be erased on each reboot.