Linux is a major force in computing technology, powering everything from mobile phones and personal computers to supercomputers and servers. The job of a systems administrator is to manage the operations of a computer system. As most computing devices are powered by Linux, it makes sense to learn it. By the end of this article, you should be able to know and understand:
- Linux file systems
- File system hierarchy
- Linux online manual page
- Root/super user
- Handling files and directories
All the commands are demonstrated using a CentOS Linux distro.
The Linux file system
A file system is a method of storing files on a hard disk. There are different types of file systems supported by Linux:
- Conventional disk file systems: ext2, ext3, ext4, XFS, Btrfs, JFS, NTFS, etc.
- Flash storage file systems: ubifs, JFFS2, YAFFS, etc.
- Special-purpose file systems: procfs, sysfs, tmpfs, debugfs, etc.
The Linux system stores files according to a standard layout called the file system hierarchy. The most common Linux directory structure is shown in Figure 1.
Linux online manual page
One of the key features of Linux is that it provides online help about every single command. To access the Linux manual (man) page, type the following command:
[bhargab@localhost~]$ man ls |
Root or super user
This is a special kind of user account, which holds all kinds of permissions to do any alteration to a program or service of Linux. The su command is used to become a root or super user. Type the following command, and enter the root password to become a root or super user.
[bhargab@localhost~]$
su
In Linux, Everything is a file. This means that when we are dealing with normal text files or with device files, we interact with them through file operation related commands. Some operations on files are discussed below.
Creating a file: There are two commands to create a file: touch and cat. The touch command simply creates an empty file. Type the following command to create an empty document:
[bhargab@localhost~]$ touch file1 |
[bhargab@localhost~]$ cat >file1 |
[bhargab@localhost~]$ cat file1 |
[bhargab@localhost~]$ cp file1 /home/bhargab/Documents/ |
Removing a file: To remove a file, type the following command:
[bhargab@localhost~]$ rm file1 |
[bhargab@localhost~]$ mv file1 /home/bhargab/Document |
To rename a file, file1 to file2, type the following command:
[bhargab@localhost~]$ mv file1 file2 |
[bhargab@localhost~]$ ls |
[bhargab@localhost~]$ ls a |
[bhargab@localhost~]$ ls l |
total 48 drwxr-xr-x. 2 bhargab bhargab 4096 Jan 25 21:32 Desktop drwxr-xr-x. 2 bhargab bhargab 4096 Apr 24 16:33 Documents drwxr-xr-x. 6 bhargab bhargab 4096 Jan 20 23:55 Downloads -rw-rw-r--. 1 bhargab bhargab 1024 Apr 28 22:18 file1 -rw-rw-r--. 1 bhargab bhargab 1024 Apr 28 22:01 file2 -rw-rw-r--. 1 bhargab bhargab 1024 Apr 28 22:01 file3 drwxr-xr-x. 2 bhargab bhargab 4096 Dec 20 08:48 Music drwxr-xr-x. 2 bhargab bhargab 4096 Dec 20 08:48 Pictures drwxr-xr-x. 2 bhargab bhargab 4096 Dec 20 08:48 Public drwxr-xr-x. 2 bhargab bhargab 4096 Dec 20 08:48 Videos |
Hard link and soft link
A link is a connection between a file name and actual data in the hard disk. There are two types of these - the hard link and soft link.
A hard link can be created by typing the following command:
[bhargab@localhost~]$ ln file1 file2 |
[bhargab@localhost~]$ ln S file1 file3 |
In Linux, every file is associated with three types of permissionsread (r), write (w), and execute (x). The existing file permission can be changed by the owner of the file or the super user. The following command will embed a write permission to the group:
[bhargab@localhost~]$ chmod g+w file1 |
[bhargab@localhost~]$ chmod o+x file1 |
[bhargab@localhost~]$ chmod g-x file1 |
The pwd command displays the current working directory, as follows:
[bhargab@localhost~]$ pwd /home/bhargab |
Creating a directory
The mkdir command is used to create a directory, as follows:
[bhargab@localhost~]$ mkdir myDir |
Removing a directory
The rmdir command is used to remove an empty directory, as shown below:
[bhargab@localhost~]$ rmdir myDir |
[bhargab@localhost~]$ rmdir p myDir |
Source http://opensourceforu.com/2016/07/introduction-linux-system-administration/
No comments:
Post a Comment