Basics Of Linux Operating SystemGetting To know The Basics Is key To Mastering Linux Programming.

Linux is an OS just like Windows and Mac OS X, but this one is an operating system’s kernel. What do you mean by that? Linux is different from other popular operating systems as it is an open-source clone of the erstwhile UNIX. This means that Linux is free to use, and you can make as many changes to personalize it and make it work according to you. That’s not all; being open source means there are several distributions or “distros” of Linux available for free. Some of the popular ones include Red Hat, Linux Ubuntu, and Linux Mint. Debian and Fedora. Linux is mainly used in building internet servers, and almost 90% of the internet is based on Linux itself. The main reason behind the same is that Linux is free, easy to manipulate, and secure. This post will introduce you to the basics of Linux operating systems and guide you to some basics of Linux operations like Navigating the Linux File System, Listing Directories, Working with the command, etc.

Moving Around Directories

The primary thing one has to learn in the basics of Linux Operating System is the art of navigating the files system of this operating system. Under this topic, the following commands will be introduce

  • pwd: Print Working Directory
  • cd: Change directory
  • Is: List Directory

Understanding The Linux File System

Like any operating system, Linux also organizes its files in a hierarchical directory system, which means they are arranged in a tree-like system of directors, also called folders. The first directory in Linux is the root directory, which contains other directories and file systems that further contain subdirectories and subfiles. Unlike Windows, which has system trees for each storage device that is attached, a Linux system has a single system tree regardless of the number of storage devices attached to the computer. It always depends on the system administrator in how they choose to manipulate these file systems.

Current Working Directory

All of us are familiar with the graphical interface of directories. One peculiar thing about these file managers is that they are upended trees. This means that the root of these trees are attached to the top while they are free from the bottom. One can always see the parent directory from which the particular directory you are working on is attached to. Coming back to the Command line, there is no graphical representation or interface structure that can accurately tell you which directory you are working in, so to display the current directory we are working in; we can use the pwd or Print Working Directory command.

Note: When we first log in to the terminal, we are logged into the home directory. Every user is given its home directory, and lbis is the only place a regular user is allowed to write commands and files.

Listing The Contents Of A Directory

To list the contents of any directory, Is command is used. To see the contents of the current working directory, one just has to type the ls in the command prompt

If you have any specific directory in mind that you want to know the content of, just mention the same after ls.

  • [email protected] -]$ ls /usr
  • bin games kerberos libexec sbin src
  • etc include lib local share tmp

you can even mention multiple directories:

  • [[email protected] ]$ ls ~ /usr
  • /home/me:
  • Desktop Documents Music Pictures Public Templates Videos
  • /user:
  •  bin games kerberos libexec sbin src etc include lib local share tmp

Changing The Current Working Directory

To change the current working directory, the cd command is used. To do this, cd followed by a well-defined pathname is used leading up to the desired directory of users. If you are wondering what a pathname is, it is the route of branches taken in a tree system to reach the desired branch of the tree.

Pathnames in Linux can be defined in either of the two ways: Absolute Pathnames or Relative Pathnames.

Absolute Pathnames

An absolute pathname, as the name suggests, is a path that is traced from ue root directory to the desired working directory until it is reached. Take the example of the bin directory: for example, you have to reach the bin directory of your system; the following commands will be followed in that case:

You can see, to reach the bin directory, the full path length has been traced. This is called using absolute pathnames.

Relative Pathnames

“The primary difference between an absolute pathname and a relative pathname is that while an absolute pathname starts from the root directory and finds its way to the desired directory, a relative pathname starts from the current directory itself and then changes it to the desired directory. To do this, some special symbols are used” .” Refers to the current directory while .” refers to the parent directory.For the same above example, the code in relative directory format shall follow as:

Options And Arguments In Is Command

Like all other commands in Linux, the Is command also uses single alphabet options and arguments command to list the directories in a specific way. The Is command has a large number of options or parameters that can be opted while listing any particular directory. Some of these parameters are given below:

  • -a
  • –all

Lists all the files under the directory, even those that are hidden and are not mentioned normally.

  • -a
  • -almost-all

Similar to -a, but it doesn’t list the current and the parent directories.

  • -d
  • -directory

Usually, the ls command lists the contents of a directory. But if you use this with -l you can get the details about the directory itself rather than the content.

  • -F
  • –classify

This option will append a character to the end of each name, like/at the end of a directory.

  • -h
  • –human-readable

In long format, display the size of the files in human-readable form rather than bytes.

  • -1

Display the results in a long format

  • -r
  • -reverse

Display content in reverse order.

  • -S

Sort the content by file size

Sort the content by modification time.

A Brief Look At The Longer Format

As we have seen before, when -l is added to Is, the content of the chosen directory is printed in a longer format with all the details mentioned in the same. Let’s look at the following example to see how to decipher that information.

  • rw-I–p– 1 root root 3576296 2007-04-03 11:05 Experience ubuntu.ogg
  • -rw-I–I– l root root 1186219 2007-04-03 11:05 kubuntuleaflet.png
  • -rw-r–I– 1 root root 47584 2007-04-03 11:05 logo-Edubuntu.png
  • -rw-r–r– 1 root root 44355 2007-04-03 11:05 logo-Kubuntu.png
  • -rw-r–p– 1 root root 34391 2007-04-03 11:05. 1logo-Ubuntu.png
  • -rw-r–[– 1 root root 32059 2007-04-03 11:05 o0-cd-cover.0dI
  • -rW-r–I– 1 root root 159744 2007-04-03 11:05 oo-derivatives.doc
  • -rw—I– 1 root root 27837 2007-04-03 11:05 oo-maxwell.00
  • -IW-I–r– 1 rot root 98816 2007-04-03 11:05 o0-trig.xls
  •  IW-I—- 1 root root 453764 2007-04-03 11:05 o0-welcome.odt
  • -rw-r–[– 1 root root 358374 2007-04-03 11:05 ubuntu Sax.099

Field -> Meaning

  • -rw-r–r–

This is the field for the access rights for a directory or a file. A – indicates a regular file while ad indicates a directory. The first three characters define the rights of the admin, the next three for the group, and the last three for other users.

  • 1

File number of the hard links.

  • root

The username of the owner of the file.

  • root

The name of the particular group that owns the file

  • 32059

This is the size of the indicated file in bytes.

  • 2007-04-03 11:05

Date and time of modification of the file.

  • co-cd-cover.odf

The file name.

Manipulation Of Files And Directories

The following topic in the post will introduce you to five of the most used Linux Commands which are namely:

  • cd: Copy directory and files
  • mv: Move or rename the file or directory
  • mkdir: Make or create directory
  • rm: remove the file or directory
  • In: Create hard and symbolic links

mkdir

The mkdir command is used to create directories; you can create one or more than one directories at the same time.

  • mkdir dir1 dir2 dir3

The above command will create directories dir1, dir2 and dir3.

cp

It is used to copy the content of a file or directory into another directory. If one needs to copy the contents of dirl to dir2, you can use:

  • cp iteml item2

While if you want to copy multiple items and save them all into a single directory, you can proceed by this:

  • cp item… directory

Options >Option -> Meaning

  • -a, –archive

Copy the content as well as the permissions and ownership of the original directory. Usually, the copy manifests the permissions and ownership of the user copying the content.

  • -I, –interactive

Before operating, confirm from the user: if this option is not selected, the system will simply overwrite the existing content.

  • -u, –update

This means when you copy some content from one place to another, only copy the content that is missing or modified, there is no need to overwrite the existing content.

  • -V, –Verbose

You can choose to display information messages as the content is being copied

mv

The mv command is used to move and rename any file depending on how you use it, and in any case, the file doesn’t have its original name once my command is used.

The syntax is mv is very similar to cp and can be used like:

  • mv item1 item2

This is to move or rename directory item1 to item2

  • mv item… directory

This is to move or rename more than one directories to another

Options -> Meaning

  • -I, –interactive

Before operating, confirm from the user;ifthis option is not selected, the system will simply overwrite the existing content.

  • -u, –update

This means when you copy some content from one place to another, only copy the content that is missing or modified, there is no need to overwrite the existing content.

  • -V, –verbose

You can choose to display information messages as the content is being copied.

rm

The rm command is used to remove files and directories.

  • rm item…

Here, the item is any file/s or directory/ies

Options

Options

Meaning

  • -I, –interactive

Before operating, confirm from the user, if this option is not selected, the system will simply delete the files without asking.

  • -v, –verbose

You can choose to display information messages as the content is being copied.

  • -I, –recursive

This command recursively deletes directories. This means that the directory being deleted has any subdirectories or subfiles; they too are deleted with them.

  • -f, –force

This command ignores non-existent files, and no prompt is displayed as it also ignores the interactive option.

Creating Links

For creating links in Linux, the In command is used. The command can be used in two ways, either

  • In file link

To create what we call a hard link or

  • In -s item link

Hard Links

A symbolic link where the item is a file or directory. Hard links are also known as the original UNIX way of creating links. Bydefault, each file in a Linux system has a hard link that gives it its name. It is important to remember that while creating a hard link, we tend to create an additional directory entry for the file.

The limitations of a hard link are:

  1. Hardlinks cannot reference a file that is not on the same storage disk as itself.
  2. Hard links may or mây not reference a directory.

Symbolic Links

Symbolic Links are more modern than hard links and were created to overcome the limitations presented by hard links. Symbolic Links work by creating a text pointer that references the file or directory we have to link. In some regards, Symbolic links work the same way as Shortcuts in Windows.

The file identified by the symbolic link and the symbolic link itself very abstract to each other. Let us say you write something in a symbolic link, and the target file is written to it. However, if you delete symbolic connections, only the link is deleted, not the file itself. If a file is deleted before the symbolic link, the link will continue to exist but will point in vain. In this case, the link is allegedly Broken. For many to use, the ls command will show broken links in the partition, as red, to reveal their presence. d

We hope this post will help you learn some Basics of the Linux Operating System. Thanks for reading this tutorial post. Visit our social media page on FacebookLinkedInTwitterTelegramTumblr, & Medium and subscribe to receive updates like this.

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/270217.html

(0)
上一篇 2022年6月24日
下一篇 2022年6月24日

相关推荐

发表回复

登录后才能评论