Linux Training : Section 3

Module 3 - System Access And File System

Important Points- Linux

  1. Linux has super-user account called “root“.

    • Root is the most powerful account that can create, modify, delete accounts and make changes to system configuration files.
  2. Linux is a case-sensitive system.

    • ABC is NOT same as abc
  3. Avoid using spaces when creating files and directories

  4. Linux kernel is not an OS. It is a small software within Linux OS that takes commands from users and pass them to system hardware or peripherals.

  5. Linux is mostly CLI (Command Line Interface) not GUI (Graphical User Interface)

  6. Linux is very flexible as compared to other OS.

PuTTY Software-

  • PuTTY software is a free and open source software tool

  • It is used to connect to remote systems and perform tasks like system administration, troubleshooting and file transfer.

Note: If you are using windows10 or above and MAC OS then we don’t need this software to connect our remote system i.e., Linux.

Connecting to Linux Machine using SSH command line-

Command Prompts and Getting Prompt Back

  • To check the ip address use- ifconfig or ip addr

  • To use ifconfig in 7.5 or later version then run yum install net-tools

  • To get your prompt back - Ctrl+C

Introduction to FileSystem

File System-

It is a system used by an OS to manage files. The system controls how data is saved or retrieved.

cd - stands for change directory. It is the primary command for moving you around the filesystem.

pwd - stands for print working directory. It tells you where your current location is.

ls -l - stands for list. It lists all the directories/files within a current working directory.

ls -ltr - it will list the files by sorting based on timestamp.

whoami - it provides the username

su - - to enter into the root directory

clear - to clear the screen

cd .. - to go back to previous directory

passwd <userid> - to change the password

rm - to remove the files and directories

Linux File and Directory Properties-

File SystemMeaning
-Regular File or text file
dDirectory
lLink
cSpecial File or device file (like keyword/mouse attached file)
sSocket
pNamed pipe
bBlock device (like Hard Drives/ USB Drives)

What is Root?

There are 3 types of root on Linux system-

  1. Root account: root is an account or a username on Linux machine and it is the most powerful account which has access to all commands and files.

  2. Root as /: the very first directory in Linux is also referred as root directory.

  3. Root home directory: the root user account also has a directory located in /root which is called root home directory.

Files System Paths-

  • There are two paths to navigate to a filesystem

    1. Absolute Path- It always begins with a “/“. Example- cd /var/log/samba

    2. Relative Path- It does not begin with a “/". Example- cd /var > cd log > cd samba

Creating Files and Directories

  • Creating Files

    1. touch - to create the empty file

    2. cp - copying a existing file and then creating a same new file

    3. vi - creating a file

      vi bart -

      to exit use - :wq!

Creating Directories

    1. mkdir

      Copying Directory-

      • cp -R <source_folder> <destination_folder>

Find Files and Directories

Two main commands are used to find files/directories

  1. find- find . -name “<filename>“

  2. locate- locate <filename>

Difference- locate uses a prebuilt database, which should be regularly updated, while find iterates over a filesystem to locate files. thus, locate is much faster than find, but can be inaccurate if the database(can be seen as a cache) is not updated. To update locate database run updatedb

WildCards-

A wildcards is a character that can be used as a substitute for any of a class of characters in a search-

  1. * - represents zero or more characters

  2. ? - represents a single characters

  3. [ ] - represents a range of characters

  4. \ - as an escape character

  5. ^ - the beginning of the line

  6. $ - the end of the line

Soft and Hard Links

  • inode - Pointer or number of a file on the hard disk

  • Soft Link = Link will be removed if file is removed or renamed

  • Hard Link = Deleting renaming or moving the original file will not affect the hard link

  1. Create a file “hulk“ in home directory then go to /tmp location and create a soft link-

  2. Add some text in the home directory file and then check for the reflection under /tmp hulk file -

  3. Now, check for the inode number for both the locations-

  4. Next step is remove the hulk from home directory and then check the details-

    Now, this /tmp location hulk file got turned into red

  1. Create a file “hulk“ in home directory then go to /tmp location and create a hard link. Add some text in the home directory file and then check for the reflection under /tmp hulk file -

  2. Add something new in the /home directory file and check for the reflection in /tmp location-

  3. Now, check for the inode and then delete the file from /home directory and then check in /tmp location, you should be able to access the hulk file-

Thanks for going through this blog, Happy Learning !! 😁