Linux is a mammoth operating system that derives its development from the millions of developers working on improving the open software. Because we cannot touch on everything, we shall start with some of the basic commands like LINUX KERNEL SYSTEM and climb up to the hard stuff.
To get into these basics, Log into the Linux system, you will require a username and password that you will use to log into the graphical user interface. The Linux kernel system has two main modes of operations i.e. the sober-quick in text console mode. This easy system looks like a DOS operating system with a multi-tasking, multi-user, and mouse. The other mode is the graphical mode, which uses more system resources, but looks and feels much better. Nowadays, the graphical mode is the most common in home computers. To know if you are logging into the graphical interface, you will be required to provide a username and password in two windows.
Perhaps I should also point out that you need to be careful when you are logging in with your account. Generally, it is not wise to log in using the root account (username). The root account is what most of us refer to as the administrator account. The reason for this is that the root account gives you the options of running extra programs with many permissions. Therefore, to keep the risk of damaging the source code at a bare minimum, I suggest that you log in using your user account and only log in using the root account when you require more permission to execute a command.
To continue, you need to call up the terminal window or Xterm. X is the name of the software supporting the graphical environment. Finding the terminal will depend on the window manager you are using. However, to navigate to it, go to Application->Utilities-internet menu or system tools (depending on your windows manager). Alternatively, you can access the Xterm by right clicking on the desktop. Because I want you to become a power user, the old point and click method will not do here. You will have to get down and meddle with the core of the system, which is what we shall learn in subsequent fields.
Most of the advanced commands have to run through the shell, which we conjured up in the terminal window where, we just learnt how to access. If you are a Windows user looking to learn Linux kernel system for administration or networking purposes, think of the terminal windows as your control panel. When you open the terminal window, it should always show a command prompt (akin to the C command in windows).
In the above instance, the terminal window displays the username and the working directory is represented by (~).
The files and systems in the Linux kernel system is where most of the users find difficulties, majorly because it is hard to tell which files are in which directories, if you don’t have the knowledge. For this reason, we shall try to look at the organization of the file systems. We shall also learn how to create, delete, move, and rename directories. Additionally, we shall learn how to edit files and change permissions.
The UNIX file system can aptly fit into a one-line description; “Everything on a UNIX system that is not a process is a file”. This statement holds true for files that are a little bit more than just files. Therefore, a Linux system does not differentiate between a file and directory mainly because the directory in essence is a file containing names of other files, services, texts, images, and programs. Additionally, a Linux system also treats input and output devices as files. The general understanding is that the files are a sort of in a tree structure on the main hard drive; this is for easy management and order. Most of the files on a Linux system are regular files, regardless of the data they hold, be it programs, executable files or normal data.
While we have already said that everything in a Linux system is a file, there is a general understanding that there are some exceptions. For instance:
Directories: A file list of other files
Special files: These are the mechanisms used for input and output. Special files are in /dev.
Links: This is a system to make a file, including directory visible in various parts of the “system tree”.
Domain (sockets): These are special types of files similar to the IP/TCP sockets. These files are protected by the file system access control and they provide inter process networking.
Named pipes: These types of files are the bridge between processes. They are more or less the same as sockets and enhance communication between processes without the use of networks or sockets semantics.
Remember that I had indicated that most computer users generalize that the file system is more or less like a tree, here is a good example of a Linux file system tree.
It is important to note that depending on the UNIX system in use, the file system tree may change; some files and directories may change.
The file system tree starts at the slash or the trunk, which, if you look at our table is the (/) forward slash. This is what we call the root directory; it is the underlying directory for all files. Directories are one level below the slash or root directory often have the slash in their proceeding names to indicate their position and to prevent confusion with other files or directories with similar names.
A question that plagues most Linux users is where programs and program files are stored when they are installed on the system. Let us examine this for a minute. Linux uses two partitions: The data partition where the system data, including the root directories and all system resources required to start the system are located, and the swap partition, which is an expansion of the physical memory on the computer. All files (including programs) are stored in this root directory in accordance to the Linux tree file system we have already looked at.
To show file names, properties, date of creation, permission, type, size, link files and owners, the Is command is the easiest way.
Creating and deleting files and directories on your system is very important when you want to create new files or delete redundant directories to free up space. Because the graphical interface is much or less that of MS DOS, creating files is not that difficult. Deleting files on the other hand is a moderately difficult. There are some popular file managers for the GNU/Linux, with most of them being executable files that are accessible from the desktop manager, home directory icon or the command line using the following commands.
Nautilus: This is the default file manager in the Gnome GNU desktop. There are very useful resources on how to use this tool online.
Konqueror: This file manager is typical in KDE desktops.
MC: Code named Midnight Commander is fashioned from the Norton commander.
For easier file management, the above applications are worth the time of reading through the documentation and the effort. It is also important to note that there are many more file management applications; but these are the most popular and have a moderate difficulty level. Additionally, these tools optimize the UNIX commands in a specific manner.
To keep files and things in one place, you must allocate specific file default locations by creating directories and subdirectories for them. You can do this by using the mkdir command. For instance:
john:~> mkdir archive john:~> ls -ld archive drwxrwxrwx 2 johnjohn 4096 Jan 13 14:09 archive/
Additionally, you can create subdirectories easily in one-step by using the – p option. For instance:
john:~> cd archive john:~/archive> mkdir 1999 2000 2001 john:~/archive>ls 1999/ 2000/ 2001/ john:~/archive>mkdir 2001/reports/Suppliers-Industrial/ mkdir: cannot create directory `2001/reports/Suppliers-Industrial/':
No such file or directory
john:~/archive>mkdir -p 2001/reports/Suppliers-Industrial/ john:~/archive>ls 2001/reports/ Suppliers-Industrial/:
In some instances, you will find that the file needs more or other permission not included in the file creation permission; this is called as an access right.
Access rights are set using the same mkdir command. It is important to note that there are rules on how to name a directory. For instance, in one directory, you cannot have two files with the same name. However, it is important to note that Linux as well as UNIX are case sensitive systems (you can have two file names with you and YOU in the same directory). Additionally, there are no limits to the length of a filename, so naming files should be a breeze. You can also use special characters in the file names as long as those characters do not hold a special meaning to the shell.
Moving unclassified files uses the mv command.
john:~/archive> mv ../report[1-4].doc reports/Suppliers-Industrial/
The same command is also in use when we are renaming files
The command can also come in handy, if you want to rename files:
In the above example, we can see that only the file name changes and all the other properties doesn’t change.
The cp command is used to copy directories and files. There is also a very useful option of copying all underlying subdirectories and files (recursive copy) which uses the –R. Here is a look at the general syntax.
cp [-R] fromfile tofile
The command rm comes into play when you want to remove single files, while the command rmdir plays its role in removing empty directories. It is important to note that some directories are undeletable (.dot and ..dot dot) because they are necessary for the proper ranking of a directory in the tree hierarchy. Like UNIX, Linux does not have a garbage can (recycle bin) and once you remove a file, that is it, it is gone and you cannot get it back unless you have a backup. To protect against this, sometimes “mistake delete”, you can activate the interactive behavior of the cp, mv, and rm commands by using the -i option. When the –i option is active, the system does not execute command such as delete immediately; instead, it prompts for confirmation, which needs that stroke of a key or an additional click to execute the command fully. For instance as shown below:
Get Updates on Tech posts, Interview & Certification questions and training schedules