0% found this document useful (0 votes)
123 views

Linux-File System

This document provides an overview of the Linux file system and various key directories. It explains that Linux uses a different file system model than Windows, with directories like /bin, /etc, /usr, /boot, and /var that store important system files and programs. The /tmp and /var directories store temporary and variable files respectively. Basic commands like ls, cd, and mount are demonstrated. Overall it serves as an introduction to navigating and understanding the Linux directory structure and file organization.

Uploaded by

manicheese
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
123 views

Linux-File System

This document provides an overview of the Linux file system and various key directories. It explains that Linux uses a different file system model than Windows, with directories like /bin, /etc, /usr, /boot, and /var that store important system files and programs. The /tmp and /var directories store temporary and variable files respectively. Basic commands like ls, cd, and mount are demonstrated. Overall it serves as an introduction to navigating and understanding the Linux directory structure and file organization.

Uploaded by

manicheese
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

File systems in Linux

This is a beginner's course and one of the concepts that newcomers to Linux find different is the idea of a file system in Linux. That is to say, the way data is stored and managed in Linux. MS-Windows and Mac users are used to clicking on an icons and dragging the files they want copied to a floppy or another part of the hard drive. Linux users that use KDE or GNOME can also copy files in that way to different parts of the hard drive. However, if you would like to use floppies, we should talk here a bit about the type of file system Linux uses. MS-Windows, from Windows 95 on up uses a file system called 'vfat' Linux uses a different system called 'ext2'. There are also other types of file systems out there. You may have chosen to have both Windows and Linux installed in your computer. At one point, you might have to access files in the Windows partition of your hard drive. You would use a command called 'mount' to do that. You would also have to indicate as an option in that command that the file system you want to access or "mount" is a Windows 'vfat' file system. On the same idea, though floppies are becoming somewhat obsolete, you may want to store some files on a floppy or access data on a floppy that someone has given to you. You would also have to use the command 'mount' before you copied data to or got data from a floppy disk. If that person is a Windows user, then you would have to indicate once again that the file system is 'vfat'. If you want to copy data from your Linux partition to a floppy, you would have to format and then "mount" the floppy as a Linux 'ext2' file system.

The Linux file system


Now's the time to learn a little bit about the Linux file system. We'll learn about where Linux puts it stuff, where to find stuff and a little bit about what that stuff is.

The Linux shell


When you're running Linux and start to type things on that black screen, you are using a shell. Any operating system uses a shell to get commands from the keyboard to the computer. It's a lot easier than punching holes in cards like they used to do in the old days. There are actually programs for Linux where you talk through a microphone and Linux will carry out commands that you've programmed in advance. It's really cool. For now, though, we'll concentrate on the keyboard. The most popular shell used for Linux is the bash shell. bash means "Bourne Again Shell". It is a free version of the Bourne shell and uses a little play on words, as you can see.

Getting in and out of directories with 'cd'


We saw a few commands in the last lesson, but we didn't go into them much. We will handle a lot of commands in more detail in later lessons. This lesson will cover those commands which you will need to see what's under Linux's hood.

The first one we should look at is 'cd'. Again MS-DOS users will be familiar with this. cd will get you in and out of directories. Try this one: cd / This will get you into the 'root' or main directory. It's the directory of directories, the king of kings, your show of shows. The root directory shouldn't be confused with root's directory. That is /root.

The basic directory structure in Linux


Now type this: ls You will probably see something like this: cdrom home opt dev bin boot lib etc proc lost+found sbin tm p usr root var

floppy mnt

They will be blue in color. Those are directories.

The /bin directory


Now type this: cd bin Type ls again. This is the famous bin/ directory. You know, I have always felt this one was misnamed. For example, when people say, 'That's no good, throw it in the bin'. Actually, bin/ is one of the most important directories in Linux. You'll find all of the most used commands there. Right now you should be seeing a lot of red (or green, depending on your version of Linux). Those are programs.

The /etc directory


Now let's look at another directory. There's a long way and a short cut. First the long way. 'cd ..' will get you out of bin/. 'cd etc' will get you into the etc/ directory. or you can just type 'cd /etc' in the bin/ directory and it will bring you to the etc/ directory . Anyway, you are now in the etc/ directory. This houses most of the configuration files for Linux. lilo.conf, the file that tells you which OS to boot is in there.

you'll see: lilo.conf And you don't even have to type the whole thing. You could just type 'ls li' and push the tab key. Linux will type the rest for you. Isn't that cool!

Some more cool short cuts


Try this one: type ls m push the tab key. Linux is going to beep a couple of times, but you keep pushing. You will now see every file in the directory that begins with the letter 'm' Now add an 'o' on to ls m so you get ls mo - now push the tab key. You should see 'motd'. This is a file that contains your startup message. SuSE has a famous one that says 'Have a lot of fun!'. I like that one so I haven't changed it, but you can change it so that Linux says anything you want when you log in. Do you want to make sure that lilo.conf is still in there? You don't have to type 'lilo.conf' or even part of it and press the tab key anymore. You just have to press the up arrow. Your last commands will appear when you do that. Your commands are saved in a history file located in your home directory. The more times you press the up button, the farther back in time you go. Pressing the down button gets you back to your most recent commands. Just stop on the command you want and press 'enter'. You can even type the command history and all of the last 400 or so commands you've typed will be presented. As you get more proficient in Linux, you'll find that this really comes in handy. You can often find out the answer to the question: How did I do that? by consulting your shell history.

The /usr directory


Let's talk about using some options with commands. For example, typing: ls -l will give you more detailed information about the contents of a directory. Try this: First let's go to the usr/ directory by doing cd /usr then type: ls -l . You will see more information, like dates, some numbers, letter combinations. It will say 'root' a lot. We'll get into more detail about what all of that means later in the course. You'll see mainly sub-directories here. The usr/ directory contains files and programs meant to be used by all of the users on the system.

In Linux, everything is a file


Yes, not only is that digital photo of The Eiffel Tower a file but your monitor is a file too! How can that be? Let's try to explain it.

The /dev directory


If you do cd /dev and then ls, you'll see a lot of yellow outlined in black. These are the devices that your system uses or can use. Everything is considered a file in Linux, so your

hard disk is kept track of as a file that sits there. If you're using an IDE hard drive (as opposed to SCSI), your hard drive will be known as /dev/hda. Don't delete that, because your hard disk will spin around, come jumping out of your computer, land on the floor and spill out ooze all over the place. No, not really. You will probably not have to look in /dev very much, so don't worry about that.

The /boot directory


Doing: cd /boot will get you into the /boot directory. You will not find any boots or shoes or footwear of any kind there. That's where the Linux kernel usually is. Power users may change the location of the kernel for reasons of their own (they may prefer /shoe), but it is normally placed there on most systems. You will eventually have to use this directory, because you may need to use two or more different types of kernels in the future. That will be taken up in a more advanced lesson.

root's directory - /root


If you are not working as 'root' and you type cd /root, you will be taken to the directory /root. However, you won't be able to do anything while you're there. Root's home directory is a restricted area for everybody else. Linux response is sort of like, 'You don't have to know that'. Users' home directories are under certain restrictions for other users as well.

The /sbin directory


/sbin is another one of those off-limits directories. You may look, but you can't touch. This directory is like /bin in that it has frequently used programs in it, but they're only meant to be used by root. 'Shutdown' is in there. Only root can shutdown the system. If a user other than root tried to shutdown the system, he or she would get a message saying that only root can do that. Then that person would be followed by the secret police for three months.

The /tmp directory


/tmp is a directory that is used to store temporary files, as the name may suggest. You will find later on that when you use a Windows-style system with Linux like KDE, this window manager will create files there for temporary use. When you double click on an icon of a photo, the photo comes up for you to see but a temporary file is created while you're looking at the photo. The temporary file is deleted when you close the KDE image program. It's mainly the programs that work under a windows manager that take advantage of this directory.

The /var directory


/var is a directory for certain files that may change their size (i.e. variable size) For example, there are a few excellent databases for Linux. One is called MySQL. Normally, MySQL keeps its data in a subdirectory of /var called /var/mysql/. If I had an e-commerce website, I would have a database to register purchases. That database would obviously grow in size. And if it didn't then I'd be in trouble. It is also the normal place where email servers store their incoming mail. Again, email varies in size as well.

The /lib directory


/lib is for library files. That's where the name /lib comes from. Programs may use libraries to carry out their functions. Different programs use the same libraries, so Linux will store them here so that every program knows where to find them. You will probably not have to worry about this directory much unless you start getting messages like 'can't find shared library...'. That will sometimes happen when you've downloaded a program and had to compile it yourself from source. Even then, getting what are known as "dependency" problems are quite rare. Most programs, even when compiled from source, usually have a pre-configuration program that makes sure that they can find what libraries they "depend" on to run. If they don't, they'll tell you that you can't install the program.

Home Sweet Home


We talked about /home before. This is a directory for storing users' personal files. All of us have certain preferences for using programs. These preferences are usually included in configuration files which are also stored in users' home directories. Most of these files start with a '.' (period/dot). If you go to your home directory, 'cd /home/[username]' and type:
ls -a

you will see these files.

Day to day with Linux


Shutting down Linux
At this point you should have installed Linux, and you've looked around at what you have. And then when you're finished you'll have to shut off your computer. Actually, there are computers that are never shut off. Imagine if your ISP shut off the computer every night! The Internet is a 24/7 business so that wouldn't be practical. There are also people who probably just shut off their monitor. As you probably get some sleep occasionally, so we should maybe let our machine have a rest too once and a while. For this, we'll use the shutdown command

The importance of the 'shutdown' command


As anyone who's used a computer knows, if you shut off you're computer before you've finished saving work, or if there's a power outage that shuts it off for you, data will be lost. At first, if you shut off Linux incorrectly or there was an inopportune thunder storm and you lost electrical power, you could do severe damage to your Linux file system. That will very rarely happen these days, but you should always use the shutdown command when you want to shut off your computer. Linux will tell you about it if you don't - it will run a check on your hard disk automatically when you use it again. If you have a big hard disk, you might as well go and make yourself a sandwich because it's going to take a while. Linux will also run a routine

check every once and a while automatically. You also have our permission to fix yourself a sandwich in these cases too.

Shutdown for a single computer


The most common way of shutting down a single user Linux system is for you as root to issue the command: shutdown -h now You use this when you plan on shutting your computer off at that moment, as opposed to some later time. You'll see a message like:
Linux is going for system halt NOW

It will start to shut off programs that you're computer is using and you'll see it all happening. That's because Linux is a transparent system. It lets you see everything it's doing. It won't give you a simple message telling you to wait and then another one telling you you can shut it off now. If something is causing a problem, it will tell you about it when it starts up and when it shuts down. That way, if you are having a problem, you may be able to track it down. If you don't know how to solve it, you can tell another person what you saw and he or she may be able to help you. With the
shutdown -h now

command, you must wait until you see the message:

System halted

or
Power down

before you shut off the computer.

Re-booting the computer


The other command that you will probably use is:
shutdown -r now

If you have installed a dual-boot system and you want to use the other operating system, (why would you want to do that?) you would use this command. You will get a similar message as with the -h (halt) option that will say something like:
System going for reboot NOW

The basic reason behind all of these messages is that Linux was conceived to be a networked operating system. You have people at workstations on the network busily doing their work. The last part of the shutdown command now is fine for a single-user home PC, but on a network system this would be changed to indicate a time. That way people would have a

chance to finish what they were doing before the system went down for maintenence. Using 'now', in a network, would probably be hazardous to the health of the person who sent that command. The next time you shutdown your system, you may want to try using some time options instead of just now. For example, you may want to try shutting down the computer at a given time.
shutdown -h 20:01

Which will shutdown the computer at 8:01 PM. You could also try:
shutdown -h +5

That shuts down the computer in 5 minutes time. Now you know the correct way to shutdown your Linux system. In the next lesson we'll talk using the system again.

You might also like