In this session, we have covered the most common directories in the Linux file tree. It also shows that on Unix everything is a file.
Many Linux distributions partially follow the Filesystem Hierarchy Standard. The FHS (Filesystem Hierarchy Standard) may help make more Unix/Linux file system trees conform better in the future. It is known from the FHS that The filesystem hierarchy standard has been designed to be used by Unix distribution developers, package developers, and system implementers. However, it is primarily intended to be a reference and is not a tutorial on how to manage a Unix filesystem or directory hierarchy.
There are some differences in the filesystems between Linux distributions. For help about your machine, enter man hier to find information about the file system hierarchy. This manual will explain the directory structure on your computer.
All Linux systems have a directory structure that starts at the root directory (the home directory of the root directory). The root directory is represented by a forward slash, like this: /. Everything that exists on your Linux system can be found below this root directory. Let's take a brief look at the contents of the root directory.
[email protected]:~$ ls / bin cdrom etc initrd.img lost+found mnt proc run srv tmp var boot dev home lib media opt root sbin sys usr vmlinuz
Binaries are files that contain compiled source code (or machine code). Binaries can be executed on the computer. Sometimes binaries are called executables.
The /bin directory contains standard system utilities. According to the FHS the /bin
directory should contain /bin/cat and /bin/date (among others).
The following information shows the common Unix/Linux commands like cat, cp, cpio, date, dd, echo, grep, and so on.
[email protected]:~$ ls /bin bash fgconsole nc sed bunzip2 fgrep nc.openbsd setfacl busybox findmnt netcat setfont bzcat fuser netstat setupcon bzcmp fusermount nisdomainname sh bzdiff getfacl ntfs-3g sh.distrib bzegrep grep ntfs-3g.probe sleep bzexe gunzip ntfs-3g.secaudit ss bzfgrep gzexe ntfs-3g.usermap static-sh bzgrep gzip ntfscat stty bzip2 hostname ntfsck su bzip2recover ip ntfscluster sync bzless kbd_mode ntfscmp tailf bzmore kill ntfsdump_logfile tar cat kmod ntfsfix tempfile chacl less ntfsinfo touch ...
You can find a /bin subdirectory in many other directories. A user named serena could put
her own programs in /home/serena/bin.
Some applications, often when installed directly from source will put themselves in /opt. A samba server installation can use /opt/samba/bin to store its binaries.
T/sbin contains binaries to configure the operating system. Many of the system binaries
require root privilege to perform certain tasks.
Below a screenshot containing system binaries to change the ip address, partition a disk and create an ext4 file system.
[email protected]:~$ ls -l /sbin/ifconfig /sbin/fdisk /sbin/mkfs.ext4 -rwxr-xr-x 1 root root 105444 Apr 16 21:37 /sbin/fdisk -rwxr-xr-x 1 root root 69484 Dec 8 2013 /sbin/ifconfig lrwxrwxrwx 1 root root 6 Jun 20 11:30 /sbin/mkfs.ext4 -> mke2fs
Binaries found in /bin and /sbin often use shared libraries located in /lib. Below is a screenshot of the partial contents of /lib.
[email protected]:/$ cd lib [email protected]:/lib$ ls apparmor libip4tc.so.0 modules brltty libip4tc.so.0.1.0 modules-load.d cpp libip6tc.so.0 plymouth crda libip6tc.so.0.1.0 recovery-mode firmware libiptc.so.0 resolvconf hdparm libiptc.so.0.0.0 systemd i386-linux-gnu libxtables.so.10 terminfo ifupdown libxtables.so.10.0.0 udev init linux-sound-base ufw klibc-SDKhWJaiUdo4OxxZ-mvprY1CZus.so lsb xtables ld-linux.so.2 modprobe.d
Typically, the Linux kernel loads kernel modules from /lib/modules/$kernel-version/. This directory is discussed in detail in the Linux kernel chapter.
We currently are in a transition between 32-bit and 64-bit systems. Therefore, you may encounter directories named /lib32 and /lib64 which clarify the register size used during compilation time of the libraries. A 64-bit computer may have some 32-bit binaries and libraries for compatibility with legacy applications. This screenshot uses the file utility to demonstrate the difference.
The ELF (Executable and Linkable Format) is used in almost every Unix-like operating system since System V.
The purpose of /opt is to store optional software. In many cases, this is software from outside the distribution repository. You may find an empty /opt directory on many systems.
A large package can install all its files in /bin, /lib, /etc subdirectories within /opt/ $packagename/. If for example the package is called wp, then it installs in /opt/wp, putting binaries in /opt/wp/bin and manpages in /opt/wp/man.
The /boot directory contains all files needed to boot the computer. These files don't change very often. On Linux systems, you typically find the /boot/grub directory here. /boot/grub contains /boot/grub/grub.cfg (older systems may still have /boot/grub/grub.conf) which defines the boot menu that is displayed before the kernel starts.
All the administrative files and configuration files should be located in /etc. Many times the name of a configuration files is the same as the application, daemon, or protocol with .conf added as the extension.
[email protected]:/$ ls /etc/*.conf /etc/adduser.conf /etc/insserv.conf /etc/pnm2ppa.conf /etc/apg.conf /etc/kernel-img.conf /etc/popularity-contest.conf /etc/blkid.conf /etc/kerneloops.conf /etc/resolv.conf /etc/brltty.conf /etc/ld.so.conf /etc/rsyslog.conf /etc/ca-certificates.conf /etc/libaudit.conf /etc/sensors3.conf /etc/colord.conf /etc/logrotate.conf /etc/signond.conf /etc/debconf.conf /etc/ltrace.conf /etc/sysctl.conf /etc/deluser.conf /etc/mke2fs.conf /etc/ts.conf /etc/fuse.conf /etc/mtools.conf /etc/ucf.conf /etc/gai.conf /etc/netscsid.conf /etc/updatedb.conf /etc/hdparm.conf /etc/nsswitch.conf /etc/usb_modeswitch.conf /etc/host.conf /etc/pam.conf /etc/wodim.conf [email protected]:/$
There is much more to be found in /etc.
A lot of Unix/Linux distributions have an /etc/init.d directory that contains scripts to start and stop daemons. This directory could disappear as Linux migrates to systems that replace the old init way of starting all daemons.
The graphical display (aka X Window System or just X) is driven by software from the X.org foundation. The configuration file for your graphical display is /etc/X11/xorg.conf.
The skeleton directory /etc/skel is copied to the home directory of a newly created user. It usually contains hidden files like a .bashrc script.
This directory, which is not mentioned in the FHS, contains a lot of Red Hat Enterprise Linux configuration files. We will discuss some of them in greater detail. The screenshot below is the /etc/sysconfig directory from RHELv4u4 with everything installed.
[email protected]:/etc$ ls /etc | more acpi adduser.conf alternatives anacrontab apg.conf apm apparmor apparmor.d apport apt aptdaemon at-spi2 avahi bash.bashrc bash_completion bash_completion.d bindresvport.blacklist blkid.conf blkid.tab bluetooth brlapi.key brltty brltty.conf --More--
The file /etc/sysconfig/firstboot tells the Red Hat Setup Agent not to run at boot time. If you want to run the Red Hat Setup Agent at the next reboot, then simply remove this file, and run chkconfig --level 5 firstboot on. The Red Hat Setup Agent allows you to install the latest updates, create a user account, join the Red Hat Network and more. It will then create the /etc/sysconfig/firstboot file again.
The /etc/sysconfig/harddisks file contains some parameters to tune the hard disks. The file explains itself.
You can see hardware detected by kudzu in /etc/sysconfig/hwconf. Kudzu is software from Red Hat for automatic discovery and configuration of hardware.
The keyboard type and keymap table are set in the /etc/sysconfig/keyboard file. For more console keyboard information, check the manual pages of keymaps(5), dumpkeys(1), loadkeys(1) and the directory /lib/kbd/keymaps/.
We will discuss networking files in this directory in the networking chapter.
Users' home directories are stored here, users can store personal or project data under /home. It is common (but not mandatory by the fhs) practice to name the users home directory after the user name in the format /home/ $USERNAME. For example:
[email protected]:/$ ls /home datasoft
Besides giving every user (or every project or group) a location to store personal files, the home directory of a user also serves as a location to store the user profile. A typical Unix user profile contains many hidden files (files whose file name starts with a dot). The hidden files of the Unix user profiles contain settings specific for that user.
On many systems /root is the default location for personal data and profile of the root user. If it does not exist by default, then some administrators create it.
You may use /srv for data that is served by your system. The FHS allows locating cvs, rsync, ftp and www data in this location. The FHS also approves administrative naming in / srv, like /srv/project55/ftp and /srv/sales/www.
On Sun Solaris (or Oracle Solaris) /export is used for this purpose.
The /media directory serves as a mount point for removable media devices such as CDROM's, digital cameras, and various usb-attached devices. Since /media is rather new in the Unix world, you could very well encounter systems running without this directory. Solaris 9 does not have it, Solaris 10 does. Most Linux distributions today mount all removable media in /media.
[email protected]:/$ ls /home datasoft
The /mnt directory should be empty and should only be used for temporary mount points (according to the FHS).
Unix and Linux administrators used to create many directories here, like /mnt/something/. You likely will encounter many systems with more than one directory created and/or mounted inside /mnt to be used for various local and remote filesystems.
Applications and users should use /tmp to store temporary data when needed. Data stored in /tmp may use either disk space or RAM. Both of which are managed by the operating system. Never use /tmp to store data that is important or which you wish to archive.
Device files in /dev appear to be ordinary files, but are not actually located on the hard disk. The /dev directory is populated with files as the kernel is recognizing hardware.
Common hardware such as hard disk devices are represented by device files in /dev. Below a screenshot of SATA device files on a laptop and then IDE attached drives on a desktop. (The detailed meaning of these devices will be discussed later.)
[email protected]:/$ ls /dev/sd* /dev/sda /dev/sda10 /dev/sda5 /dev/sda7 /dev/sda9 /dev/sda1 /dev/sda2 /dev/sda6 /dev/sda8
Besides representing physical hardware, some device files are special. These special devices can be very useful.
For example, /dev/tty1 represents a terminal or console attached to the system. (Don't break your head on the exact terminology of 'terminal' or 'console', what we mean here is a command line interface.) When typing commands in a terminal that is part of a graphical interface like Gnome or KDE, then your terminal will be represented as /dev/pts/1 (1 can be another number).
/proc is another special directory, appearing to be ordinary files, but not taking up disk space. It is actually a view of the kernel, or better, what the kernel manages, and is a means to interact with it directly. /proc is a proc filesystem.
[email protected]:/$ mount -t proc proc on /proc type proc (rw,noexec,nosuid,nodev)
When listing the /proc directory you will see many numbers (on any Unix) and some interesting files (on Linux)
[email protected]:/$ ls /proc 1 1632 19 2195 34 751 cpuinfo mounts 10 1635 1901 22 346 754 crypto mtrr 1014 1643 1904 2201 35 761 devices net 1063 1647 1909 2202 36 78 diskstats pagetypeinfo 11 1656 1927 2261 37 79 dma partitions 1107 1660 1931 2272 417 8 driver sched_debug 1130 1664 1935 23 481 80 execdomains schedstat 12 1667 1949 2302 49 802 fb scsi 13 1686 1954 2308 495 846 filesystems self 1323 1695 1958 2315 5 885 fs slabinfo 136 17 1962 2324 50 888 interrupts softirqs 137 1709 1977 24 52 889 iomem stat 1498 1710 2 2481 53 896 ioports swaps 15 1712 20 25 54 9 ipmi sys 1500 1714 2012 2503 55 949 irq sysrq-trigger 1563 1723 2057 2551 565 954 kallsyms sysvipc 1571 1724 2067 26 577 957 kcore timer_list 1580 1725 2082 27 592 975 key-users timer_stats 1586 1730 2090 2726 596 984 kmsg tty 1598 1744 21 276 597 986 kpagecount uptime 16 1760 2105 28 618 995 kpageflags version 1614 1772 2110 282 638 acpi latency_stats version_signature 1618 1794 2117 29 671 asound loadavg vmallocinfo 1622 18 2129 3 679 buddyinfo locks vmstat 1623 1804 2143 31 7 bus mdstat zoneinfo 1625 1813 2152 319 740 cgroups meminfo 1626 1818 2159 32 744 cmdline misc 1631 1898 2182 33 750 consoles modules
Let's investigate the file properties inside /proc. Looking at the date and time will display the current date and time showing the files are constantly updated (a view on the kernel).
[email protected]:/$ date Wed Jul 30 16:13:52 IST 2014 [email protected]:/$ ls -al /proc/cpuinfo -r--r--r-- 1 root root 0 Jul 30 16:14 /proc/cpuinfo [email protected]:/$ [email protected]:~$ date Wed Jul 30 17:28:27 IST 2014 [email protected]:~$ ls -al /proc/cpuinfo -r--r--r-- 1 root root 0 Jul 30 17:28 /proc/cpuinfo
Most files in /proc are 0 bytes, yet they contain data--sometimes a lot of data. You can see this by executing cat on files like /proc/cpuinfo, which contains information about the CPU.
[email protected]:~$ file /proc/cpuinfo /proc/cpuinfo: empty [email protected]:~$ cat /proc/cpuinfo processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 42 model name : Intel(R) Pentium(R) CPU G620 @ 2.60GHz stepping : 7 microcode : 0x25 cpu MHz : 1600.000 cache size : 3072 KB physical id : 0 siblings : 2 core id : 0 cpu cores : 2 apicid : 0 initial apicid : 0 fdiv_bug : no f00f_bug : no coma_bug : no fpu : yes fpu_exception : yes cpuid level : 13 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx rdtscp lm constant_tsc arch_perfmon pebs bts xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 popcnt tsc_deadline_timer xsave lahf_lm arat epb xsaveopt pln pts dtherm tpr_shadow vnmi flexpriority ept vpid bogomips : 5188.25 clflush size : 64 cache_alignment : 64 address sizes : 36 bits physical, 48 bits virtual power management: processor : 1 vendor_id : GenuineIntel cpu family : 6 model : 42 model name : Intel(R) Pentium(R) CPU G620 @ 2.60GHz stepping : 7 microcode : 0x25 cpu MHz : 1600.000 cache size : 3072 KB physical id : 0 siblings : 2 core id : 1 cpu cores : 2 apicid : 2 initial apicid : 2 fdiv_bug : no f00f_bug : no coma_bug : no fpu : yes fpu_exception : yes cpuid level : 13 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx rdtscp lm constant_tsc arch_perfmon pebs bts xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 popcnt tsc_deadline_timer xsave lahf_lm arat epb xsaveopt pln pts dtherm tpr_shadow vnmi flexpriority ept vpid bogomips : 5188.25 clflush size : 64 cache_alignment : 64 address sizes : 36 bits physical, 48 bits virtual power management: [email protected]:~$
Just for fun, here is /proc/cpuinfo on a Sun Sunblade 1000...
[email protected]:~$ cat /proc/cpuinfo | more processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 42 model name : Intel(R) Pentium(R) CPU G620 @ 2.60GHz stepping : 7 microcode : 0x25 cpu MHz : 1600.000 cache size : 3072 KB physical id : 0 siblings : 2 core id : 0 cpu cores : 2 apicid : 0 initial apicid : 0 fdiv_bug : no f00f_bug : no coma_bug : no fpu : yes fpu_exception : yes cpuid level : 13 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov --More--
Most of the files in /proc are read only, some require root privileges, some files are writable, and many files in /proc/sys are writable. Let's discuss some of the files in /proc.
On the x86 architecture, /proc/interrupts displays the interrupts.
[email protected]:~$ cat /proc/interrupts CPU0 CPU1 0: 16 0 IO-APIC-edge timer 1: 2 0 IO-APIC-edge i8042 7: 0 0 IO-APIC-edge parport0 8: 1 0 IO-APIC-edge rtc0 9: 3 0 IO-APIC-fasteoi acpi 12: 4 0 IO-APIC-edge i8042 16: 29 0 IO-APIC-fasteoi ehci_hcd:usb1 19: 17283 26337 IO-APIC-fasteoi ata_piix, ata_piix 23: 55734 64589 IO-APIC-fasteoi ehci_hcd:usb2 40: 13 0 PCI-MSI-edge mei_me 41: 500032 0 PCI-MSI-edge i915 42: 470 0 PCI-MSI-edge snd_hda_intel 43: 43010 0 PCI-MSI-edge eth0 NMI: 24 26 Non-maskable interrupts LOC: 359598 369234 Local timer interrupts SPU: 0 0 Spurious interrupts PMI: 24 26 Performance monitoring interrupts IWI: 9565 11827 IRQ work interrupts RTR: 0 0 APIC ICR read retries RES: 101165 71652 Rescheduling interrupts CAL: 202 596 Function call interrupts TLB: 3370 6154 TLB shootdowns TRM: 0 0 Thermal event interrupts THR: 0 0 Threshold APIC interrupts MCE: 0 0 Machine check exceptions MCP: 42 42 Machine check polls ERR: 0 MIS: 0
On a machine with two CPU's, the file looks like this.
[email protected]:~$ cat /proc/interrupts CPU0 CPU1 0: 16 0 IO-APIC-edge timer 1: 2 0 IO-APIC-edge i8042 7: 0 0 IO-APIC-edge parport0 8: 1 0 IO-APIC-edge rtc0 9: 3 0 IO-APIC-fasteoi acpi 12: 4 0 IO-APIC-edge i8042 16: 29 0 IO-APIC-fasteoi ehci_hcd:usb1 19: 17283 26337 IO-APIC-fasteoi ata_piix, ata_piix 23: 55734 64589 IO-APIC-fasteoi ehci_hcd:usb2 40: 13 0 PCI-MSI-edge mei_me 41: 500032 0 PCI-MSI-edge i915 42: 470 0 PCI-MSI-edge snd_hda_intel 43: 43010 0 PCI-MSI-edge eth0 NMI: 24 26 Non-maskable interrupts LOC: 359598 369234 Local timer interrupts SPU: 0 0 Spurious interrupts PMI: 24 26 Performance monitoring interrupts IWI: 9565 11827 IRQ work interrupts RTR: 0 0 APIC ICR read retries RES: 101165 71652 Rescheduling interrupts CAL: 202 596 Function call interrupts TLB: 3370 6154 TLB shootdowns TRM: 0 0 Thermal event interrupts THR: 0 0 Threshold APIC interrupts MCE: 0 0 Machine check exceptions MCP: 42 42 Machine check polls ERR: 0
The physical memory is represented in /proc/kcore. Do not try to cat this file, instead use a debugger. The size of /proc/kcore is the same as your physical memory, plus four bytes.
[email protected]:~$ ls -lh /proc/kcore -r-------- 1 root root 1020M Jul 30 17:41 /proc/kcore [email protected]:~$
The /sys directory was created for the Linux 2.6 kernel. Since 2.6, Linux uses sysfs to support usb and IEEE 1394 (FireWire) hot plug devices. See the manual pages of udev(8) (the successor of devfs) and hotplug(8) for more info (or visit http://linuxhotplug. sourceforge.net/ ).
Basically the /sys directory contains kernel information about hardware.
Although /usr is pronounced like user, remember that it stands for Unix System Resources. The /usr hierarchy should contain shareable, read only data. Some people choose to mount /usr as read only. This can be done from its own partition or from a read only NFS share.
The /usr/bin directory contains a lot of commands.
[email protected]:~$ ls /usr/bin | wc -l 1421
The /usr/include directory contains general use include files for C.
[email protected]:~$ ls /usr/include/ aio.h fcntl.h math.h pwd.h sysexits.h aliases.h features.h mcheck.h python2.7 syslog.h alloca.h fenv.h memory.h rdma tar.h argp.h fmtmsg.h mntent.h re_comp.h termio.h argz.h fnmatch.h monetary.h regex.h termios.h ar.h fstab.h mqueue.h regexp.h tgmath.h arpa fts.h mtd resolv.h thread_db.h asm-generic ftw.h nautilus-sendto rpc time.h assert.h _G_config.h net rpcsvc ttyent.h ...
The /usr/lib directory contains libraries that are not directly executed by users or scripts.
[email protected]:~$ ls /usr/lib | head -7 2013.com.canonical.certification:checkbox 2013.com.canonical.certification:plainbox-resources accountsservice aisleriot apg apt aspell
The /usr/local directory can be used by an administrator to install software locally.
[email protected]:~$ ls /usr/local/ bin etc games include lib man sbin share src [email protected]:~$ du -sh /usr/local 11M /usr/local
The /usr/share directory contains architecture independent data. As you can see, this is a fairly large directory.
[email protected]:~$ ls /usr/share/ | wc -l 283 [email protected]:~$ du -sh /usr/share/ 1.1G /usr/share/
This directory typically contains /usr/share/man for manual pages.
[email protected]:~$ ls /usr/share/man ar [email protected] en_GB fr hr ko man5 nb pt_BR sq uk ast cs eo fr.ISO8859-1 hu ku man6 nl ro sr uz be cy es fr.UTF-8 id lt man7 nn ru sv vi bg da et fy io lv man8 oc se ta zh_CN bn de eu gd it man1 mhr pa shn te zh_HK bo el fa gl ja man2 ml pl si th zh_TW bs en_AU fi he kk man3 ms ps sk tr ca en_CA fo hi km man4 my pt sl ug
And it contains /usr/share/games for all static game data (so no high-scores or play logs).
[email protected]:~$ ls /usr/share/games/ ls: cannot access /usr/share/games/: No such file or directory
The /usr/src directory is the recommended location for kernel source files.
[email protected]:~$ ls -l /usr/src/ total 8 drwxr-xr-x 24 root root 4096 Apr 17 06:54 linux-headers-3.13.0-24 drwxr-xr-x 7 root root 4096 Apr 17 06:55 linux-headers-3.13.0-24-generic
Files that are unpredictable in size, such as log, cache and spool files, should be located in /var.
The /var/log directory serves as a central point to contain all log files.
[email protected]:~$ ls /var/log alternatives.log dist-upgrade fsck syslog apport.log dmesg gpu-manager.log syslog.1 apport.log.1 dmesg.0 hp syslog.2.gz apport.log.2.gz dmesg.1.gz installer udev apt dmesg.2.gz kern.log unattended-upgrades auth.log dmesg.3.gz lastlog upstart boot.log dmesg.4.gz lightdm wtmp bootstrap.log dpkg.log pm-powersave.log Xorg.0.log btmp faillog samba Xorg.0.log.old cups fontconfig.log speech-dispatcher
A typical first file to check when troubleshooting on Red Hat (and derivatives) is the /var/ log/messages file. By default this file will contain information on what just happened to the system. The file is called /var/log/syslog on Debian and Ubuntu.
The /var/cache directory can contain cache data for several applications.
[email protected]:/$ ls /var/cache/ apparmor cups fontconfig pm-utils apt debconf ldconfig pppconfig apt-xapian-index dictionaries-common lightdm samba cracklib flashplugin-installer man software-center
The /var/spool directory typically contains spool directories for mail and cron, but also serves as a parent directory for other spool files (for example print spool files).
The /var/lib directory contains application state information.
Red Hat Enterprise Linux for example keeps files pertaining to rpm in /var/lib/rpm/.
/var also contains Process ID files in /var/run (soon to be replaced with /run) and temporary files that survive a reboot in /var/tmp and information about file locks in /var/lock. There will be more examples of /var usage further in this tutorial.
1. Does the file /bin/cat exist ? What about /bin/dd and /bin/echo. What is the type of these files ?
ls /bin/cat ; file /bin/cat
ls /bin/dd ; file /bin/dd
ls /bin/echo ; file /bin/echo
2. What is the size of the Linux kernel file(s) (vmlinu*) in /boot ?
3. Create a directory ~/test. Then issue the following commands:
dd if=/dev/zero of=zeroes.txt count=1 bs=100
dd will copy one times (count=1) a block of size 100 bytes (bs=100) from the file /dev/zero to ~/test/zeroes.txt. Can you describe the functionality of /dev/zero ?
dd if=/dev/zero of=zeroes.txt count=1 bs=100
dd will copy one times (count=1) a block of size 100 bytes (bs=100) from the file /dev/zero
to ~/test/zeroes.txt. Can you describe the functionality of /dev/zero ?
/dev/zero is a Linux special device. It can be considered a source of zeroes. You cannot send
something to /dev/zero, but you can read zeroes from it.
4. Now issue the following command:
dd will copy one times (count=1) a block of size 100 bytes (bs=100) from the file /dev/ random to ~/test/random.txt. Can you describe the functionality of /dev/random ?
dd if=/dev/random of=random.txt count=1 bs=100 ; od random.txt
dd will copy one times (count=1) a block of size 100 bytes (bs=100) from the file /dev/
random to ~/test/random.txt. Can you describe the functionality of /dev/random ?
/dev/random acts as a random number generator on your Linux machine.
5. Issue the following two commands, and look at the first character of each output line.
ls -l /dev/sd* /dev/hd*
ls -l /dev/tty* /dev/input/mou*
The first ls will show block(b) devices, the second ls shows character(c) devices. Can you tell the difference between block and character devices ?
ls -l /dev/sd* /dev/hd*
ls -l /dev/tty* /dev/input/mou*
The first ls will show block(b) devices, the second ls shows character(c) devices. Can you
tell the difference between block and character devices ?
Block devices are always written to (or read from) in blocks. For hard disks, blocks of 512
bytes are common. Character devices act as a stream of characters (or bytes). Mouse and
keyboard are typical character devices.
6. Use cat to display /etc/hosts and /etc/resolv.conf. What is your idea about the purpose of these files?
/etc/hosts contains hostnames with their ip address
/etc/resolv.conf should contain the ip address of a DNS name server.
7. Are there any files in /etc/skel/ ? Check also for hidden files.
Issue "ls -al /etc/skel/". Yes, there should be hidden files there.
8. Display /proc/cpuinfo. On what architecture is your Linux running ?
The file should contain at least one line with Intel or other cpu.
9. Display /proc/interrupts. What is the size of this file ? Where is this file stored ?
The size is zero, yet the file contains data. It is not stored anywhere because /proc is a
virtual file system that allows you to talk with the kernel. (If you answered "stored in RAMmemory,
that is also correct...).
10. Can you enter the /root directory ? Are there (hidden) files ?
Try "cd /root". Yes there are (hidden) files there.
11.Are ifconfig, fdisk, parted, shutdown and grub-install present in /sbin ? Why are these binaries in /sbin and not in /bin ?
Because those files are only meant for system administrators.
12. Is /var/log a file or a directory ? What about /var/spool ?
Both are directories.
13. Open two command prompts (Ctrl-Shift-T in gnome-terminal) or terminals (Ctrl-Alt-F1,
Ctrl-Alt-F2, ...) and issue the who am i in both. Then try to echo a word from one terminal
to the other.
tty-terminal: echo Hello > /dev/tty1
pts-terminal: echo Hello > /dev/pts/1
14. Read the man page of random and explain the difference between /dev/random and / dev/urandom.