✍️
Notes.md
  • Table of contents
  • React.Js
    • React Hooks
    • Old :- React : Using Classes
  • Blockchain
    • Solidity
    • Custom ERC20 token
    • Contract
  • Tools and Tech
    • Docker
    • Git version Control
  • Java
    • Data & Data Types
    • IO in Java
    • Data Structures
      • Array in Java
      • Collections in Java
      • Map in Java
      • Enums in Java
      • Linked List in Java
      • List in Java
      • Queues & Stacks
      • Set in Java
      • TreeSet and TreeMap
    • Object Oriented Programming
      • Object Class Methods and Constructor
      • Immutable Class & Objects
      • Constructors
      • Visibility
      • Generics
    • Threads in Java
    • Useful Stuff Java
      • Lambda & Stream
    • Keywords in Java
      • Annotations
      • Comparators
      • Packages in Java
    • Miscellaneous
    • Articles to refer to
  • Golang
    • Competitive Programming in Go
    • Testing simple web server
    • Learning Go : Part 1
    • Maps vs slices
    • Golang Garbage Collector 101
    • Things Golang do differently
    • Go Things
  • Linux
    • Shell programming
    • Linux Commands Part 1 - 4
    • Linux Commands Part 5 - 8
    • Linux Commands Part 9 - 10
  • Software Design
    • Solid Design
    • OOPS
    • Design Patterns
      • Creational Design Pattern
        • Builder DP
        • Factory DP
        • Singleton DP
      • Adapter DP
      • Bridge DP
      • Iterator DP
      • State DP
      • Strategy DP
      • Behavioral Design Pattern
        • Observer DP
      • Structural Design Pattern
        • Facade DP
  • Cloud
    • Google Cloud Platform
      • GCP Core Infrastructure
      • Cloud Networking
  • Spring Boot
    • Spring Basics
      • Spring Beans
      • Important Annotations
      • Important Spring Things
      • Maven Things
      • Spring A.O.P
    • Spring Boot Controller
      • Response Entity Exception Handling
    • Spring Things
    • Spring MVC
    • Spring Data
      • Redis
      • Spring Data JPA
      • JDBC
    • Apache Camel
  • Miscellaneous
    • Troubleshooting and Debugging
Powered by GitBook
On this page
  • Introductory Commands
  • File Structure
  • Symbolic Links | Soft Link | Symlink
  • Manipulating Files and Directories
  • Hard Links vs Soft Links
  • Hard Link
  • Soft Link
  • WildCards

Was this helpful?

  1. Linux

Linux Commands Part 1 - 4

PreviousShell programmingNextLinux Commands Part 5 - 8

Last updated 2 years ago

Was this helpful?

Tags: linux-com-book

Introductory Commands

  • # before terminal means super-user

  • date to print date and time

    • Sat Jun 18 12:01:17 AM IST 2022

  • cal to print calendar

  • df to print disk drive and usage

  • free to print memory

  • pwd print working directory

  • Absolute PathName : begins with root directory and follows the tree branch by branch till the desired folder

  • Relative PathName : starts from the working directory

  • cd to change directory

    • cd - to revert to previous directory

    • cd ~username : to change directory to another user

  • ls : to list directories

    • ls directory_1 directory_2 : to print list or multiple directories

    ➜  ~ ls programm software
    programm:
    azure-dev-hackathon  inbox-app            
    configs              learning-springboot  
    demo                 playground           
    
    software:
    jetbrains-toolbox  tor-browser_en-US
    • ls -l : for more details

    • ls -lt : to list sorted acc. date modifed

      • —reverse : to reverse the sort

Long Listing Details

  • file filename : to print a brief description of the file’s contents

  • less : to view content of file

File Structure

Symbolic Links | Soft Link | Symlink

  • symbolic links are like aliases or another name for the file

lrwxrwxrwx 1 root root
11 2018-08-11 07:34 libc.so.6 ***->*** libc-2.6.so

Why they are useful ?

  • Imagine we have a file with name foo . Whenever we update it we, change its name to foo-date-time, but the programs/user referencing it wouldst know that the name has change. To tackle this problem, we create a symlink of file foo → foo-date-time and the programs/user user only reference the symlink.

  • So even if we change the name of file foo, it wont affect the programs as they would be referencing the symlink.

Manipulating Files and Directories

  • to create new directories

    • mkdir dir_name

  • to create multiple directories

    • mkdir dir1 dir2 dir3

  • to copy file to another directory

    • cp item directory

    • if cp item1 item2 then content of item2 is replace with item1

  • use -a file while copying to copy the attributes as well

  • The mv command performs both file moving and file renaming, depending on how it is used

  • to move item to another directory mv item... directory

  • to delete item rm item

Hard Links vs Soft Links

Hard Link

  • Hard links are the original Unix way of creating links

  • Every file has a single hard link that gives the file its name

  • Limitations

    • A hard link cannot reference a file outside its own file system

    • A hard link may not reference a directory

  • A hard link is indistinguishable from the file itself

// for hard link
-> ln file.txt link

-> ls
-rw-r--r--. 1 udayyadav udayyadav  12 Jun 20 23:06 file.txt
-rw-r--r--. 2 udayyadav udayyadav  12 Jun 20 23:06 link1

Soft Link

  • They work by creating a special type of file that contains a text pointer to the referenced file or directory

  • They are like windows shortcuts

  • If file is deleted, then link points to nothing, it is broken

// for soft link
-> ln -s file.txt link

-> ls
lrwxrwxrwx. 1 udayyadav udayyadav   9 Jun 21 07:59 link2 -> file2.txt

WildCards

List of options of ls command
details of fields printing long list
Linux file structure part 1
Linux file structure part 2
Linux file structure part 3
Linux file structure part 4
Linux file structure part 5
options for cp command
options for rm command
different wildcards present
matching with different characters
wildcard example