From d98a93fdd46db38614bceaa8e2c40e2dd1121b17 Mon Sep 17 00:00:00 2001 From: externref Date: Mon, 23 Sep 2024 20:15:10 +0530 Subject: [PATCH] Deployed 5c38155 with MkDocs version: 1.6.1 --- .../index.html | 824 ++++++++++++++++++ 404.html | 160 +++- archive/2023/index.html | 522 +++++++++++ category/cli/index.html | 524 +++++++++++ category/linux/index.html | 524 +++++++++++ category/shell/index.html | 524 +++++++++++ index.html | 214 ++++- 7 files changed, 3288 insertions(+), 4 deletions(-) create mode 100644 2023/09/23/linux-how-tos---a-must-know-list-of-commands-in-linux-shells/index.html create mode 100644 archive/2023/index.html create mode 100644 category/cli/index.html create mode 100644 category/linux/index.html create mode 100644 category/shell/index.html diff --git a/2023/09/23/linux-how-tos---a-must-know-list-of-commands-in-linux-shells/index.html b/2023/09/23/linux-how-tos---a-must-know-list-of-commands-in-linux-shells/index.html new file mode 100644 index 0000000..99b6083 --- /dev/null +++ b/2023/09/23/linux-how-tos---a-must-know-list-of-commands-in-linux-shells/index.html @@ -0,0 +1,824 @@ + + + + + + + + + + + + + + + + + + + Linux How-TOs ❓ | A must know list of commands in Linux shells - yap + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + Skip to content + + +
+
+ +
+ + + + + + +
+ + +
+ +
+ + + + + + +
+
+ + + + + + + + + + + + + + + +
+
+
+
+ + +
+
+
+
+ + + + +

Linux How-TOs ❓ | A must know list of commands in Linux shells

+

Hello Everyone 👋.

+

Here's a list of useful tools and commands that are required often for using Linux as a daily driver or even only for development.

+ +

This article will cover commands from bash, zsh, and fish since they are mostly compatible.

+

Topics covered in this article

+

Concepts: Environment variables, Aliasing, Path +Built in commands: set(fish), cd, pwd, ls, mkdir, touch, cat, echo, rm, cp, mv, grep, wget, tar +Installable commands: nano, mousepad

+

Basics

+

Before starting with commands here are some core concepts you should be aware of: +* ~ in a path represents the home directory (eg: /home/username/ ) +* / represents the root directory +* Values starting with a $ denote an environment variable. For example, $HOME returns the path to your home directory. If the environment variable is not found an empty string is returned.

+
sarthak@sarthak ~> echo $HOME
+/home/sarthak
+sarthak@sarthak ~> echo $THIS_ENV_DONT_EXIST
+
+sarthak@sarthak ~>  
+
+
    +
  • There might be some differences between syntax patterns in different shells, in that case, alternatives will be used.
  • +
+

These are basic commands you should know to use the terminal efficiently.

+

Environment Variables

+

Environment variables are used to store values for a process into the system, there are several Environment variables like PATH, PWD, USER etc set up by the processes on the system. Here are some operations you can perform on them. +

# reading a env variable
+echo $HOME # prefixing the name with $
+ENV_NAME="VALUE" # setting value for a session
+# Example
+sarthak@sarthak:~$ VAR2="sarthak in bash" # using bash
+sarthak@sarthak:~$ echo $VAR1 $VAR2
+sarthak in bash
+sarthak@sarthak ~> set VAR1 "sarthak in fish" # using fish
+sarthak@sarthak ~> echo $VAR1
+sarthak in fish
+

+
+

Creating aliases

+

You can create aliases for long commands using alias command. These are useful when you need to repeat same task multiple times. +

alias [ALIAS] [COMMAND]
+
+Example

+

grep example

+
+

The PATH variable

+

The path variable stores directory addresses where executable files are stored. These are stored in a single string seperated by a colons. You can access the path using the PATH variable in the shell. +Adding a path temporarily +To add a path temporarily you can use the export command in the active shell +

export PATH=$PATH:/path/to/directory # for bash and zsh
+fish_add_path /path/to/directory # for fish
+
+This will add the PATH to the path variable for current shell session. +Adding a path permanently +You need to edit your RC file which should be named after your shell ( .bashrc, .zshrc) to execute the commands from above. For fish shell you need to add the set command in ~/.config/fish/config.fish

+
+ +
    +
  • cd: The cd command is used to move from one directory to another. The syntax for the command is +
    cd [DIRECTORY] # where directory is the path of the directory to navigate to 
    +cd .. # to navigate to the parent directory of your current
    +# you can also navigate to other dir in the parent dir
    +cd ../other_directory_in_parent_directory 
    +cd ~ # for the home directory
    +cd / # for the root directory
    +
    +# exclusive to fish, you can type in the directory path directly
    +directory/
    +
  • +
  • pwd: Print Working Directory prints the path to the current working directory. +
    # example
    +sarthak@sarthak ~/p/codeforces (main)> pwd
    +/home/sarthak/projects/codeforces
    +
  • +
  • ls: This is used to list the contents of a directory. Command syntax: +
    ls [DIR_NAME=pwd] # current directory is listed by default
    +ls -R # shows files and folders inside the dir recusively
    +# you don't want to use the -R tag most of the times.
    +
  • +
+
+

Working with directories and files

+
    +
  • mkdir: The mkdir command is used to make directories in the current working directory. Command syntax: +
    mkdir [DIRECTORY_NAME] # creates a directory with the name provided
    +# if the directory is a subdirectory and the parent dir does not exist
    +mkdir -p [DIRECTORY_PATH] 
    +# example
    +mkdir hello/world # will error since dir hello does not exist
    +mkdir -p hello/world # will create hello dir with world dir inside it
    +
  • +
  • touch: This command is actually meant to modify edit and create time of files, but can also be used to create them. Command syntax: +
    touch hello.txt # creates a new file called hello.txt
    +
  • +
  • cat: This command is used to concatinate the contents of file(s) and display them. Command Syntax: +
    cat [FILE(s)]
    +# example
    +cat file1.txt file2.txt
    +
  • +
  • echo: The echo command is mainly used to display text in the stdout but can also be used to write in a file. Command syntax: +
    echo "text to display in shell"
    +echo "text to display in file" > filename
    +# Example
    +sarthak@sarthak ~> echo "import hello" > main.py
    +sarthak@sarthak ~> cat main.py
    +import hello
    +
  • +
  • rm: The rm command is used to remove files or dirs specified in the argument. Some useful flags for this command are:
      +
    • r: recursively remove items from the directory
    • +
    • f: ignore files that do not exist without any prompts
    • +
    +
  • +
+

Command Syntax: +

rm <flags> [TARGET] 
+# Example
+rm hello.txt # will remove the hello.txt file 
+rm -rf src/ 
+# will remove all the files and dirs inside the src dir and delete it
+

+
    +
  • cp: This command is used to create a copy of a file. Command syntax: +
    cp [SOURCE_FILE] [TARGET_FILE] # target file created if doesn't exist
    +# Example
    +sarthak@sarthak ~> cat hello.py
    +import hello
    +sarthak@sarthak ~> cp hello.py test.py
    +sarthak@sarthak ~> cat test.py
    +import hello
    +
  • +
  • mv: The move command is used to move the file from one location to another. It can also be used to rename the file. +
    mv [FILE] [TARGET] # target can be a directory or a file name
    +# Example
    +sarthak@sarthak ~> mkdir test_dir
    +# moving to a new directory
    +sarthak@sarthak ~> mv hello.py test_dir/
    +sarthak@sarthak ~> cat test_dir/hello.py
    +import hello
    +# renaming the file
    +sarthak@sarthak ~> mv test_dir/hello.py test_dir/renamed_file.py
    +sarthak@sarthak ~> cat test_dir/renamed_file.py
    +import hello
    +
  • +
  • +

    grep: The grep command is used to find for text in a file. Command syntax +

    grep <tags> [STR_TO_SEARCH_FOR] [FILENAME]
    +# Example
    +sarthak@sarthak ~ [1]> grep "py" space/src/lib.rs
    +use pyo3::prelude::*;
    +#[pyfunction]
    +#[pymodule(name="space")]
    +    m.add_function(wrap_pyfunction!(test_function, m)?)?;
    +# For better output use the --color and -n tags
    +# it will highlight the output and add line numbers to the matches
    +
    +grep example

    +
  • +
  • +

    wget: This utility is used to download files to the local system. +Command Syntax: +

    wget <-c> [URL] # the c tag is used to establish a continous download
    +# Example
    +sarthak@sarthak ~> wget -c https://bootstrap.pypa.io/get-pip.py
    +--2024-08-24 08:01:29--  https://bootstrap.pypa.io/get-pip.py
    +Resolving bootstrap.pypa.io (bootstrap.pypa.io)... 151.101.156.175, 2a04:4e42:25::175
    +Connecting to bootstrap.pypa.io (bootstrap.pypa.io)|151.101.156.175|:443... connected.
    +HTTP request sent, awaiting response... 200 OK
    +Length: 2266755 (2.2M) [text/x-python]
    +Saving to: ‘get-pip.py’
    +
    +get-pip.py                    100%[=================================================>]   2.16M  10.3MB/s    in 0.2s
    +
    +2024-08-24 08:01:30 (10.3 MB/s) - ‘get-pip.py’ saved [2266755/2266755]
    +

    +
  • +
+
+

Text Editing

+

Text editing tools like nano and vim come pre installed on most linux distributions. You can use nano for basic text editing inside the terminal. +Usage: nano [FILENAME] +Alternatively you can use mousepad for GUI based editing. +Usage: mousepad [FILENAME]

+

nano usage

+
+

Working with Archives

+

The tar command is used to work with tar.gz format which is mostly used in linux OS(s). +Usage: tar [options] [archive-file] +You can use this command to unarchive files. +

tar -cvzf [archive].tar.gz [FOLDER NAME]
+

+
+

These are the commands I use for development using Ubuntu(WSL) and Arch(Bare Metal) as a daily driver. Fell free to comment for improvements and other relevant useful information that can be added 😄.

+ + + + + + + + + + + + + + + + + + +
+
+ + + +
+ +
+ + + +
+
+
+
+ + + + + + + + + + \ No newline at end of file diff --git a/404.html b/404.html index 998604a..fbb92d0 100644 --- a/404.html +++ b/404.html @@ -202,19 +202,175 @@ -
  • - + + + + +
  • + + + + + + + + + +
  • + + + + + + + + + + + + + +
  • + + + + + + + + + + +
  • + + diff --git a/archive/2023/index.html b/archive/2023/index.html new file mode 100644 index 0000000..3cfbf02 --- /dev/null +++ b/archive/2023/index.html @@ -0,0 +1,522 @@ + + + + + + + + + + + + + + + + + + + + + 2023 - yap + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + Skip to content + + +
    +
    + +
    + + + + + + +
    + + +
    + +
    + + + + + + +
    +
    + + + +
    +
    +
    + + + + + +
    +
    +
    + + + +
    +
    +
    + + + +
    +
    +
    + + + +
    +
    +
    +

    2023

    +
    + + + + + + + + + + + + +
    +
    + + + +
    + +
    + + + +
    +
    +
    +
    + + + + + + + + + + \ No newline at end of file diff --git a/category/cli/index.html b/category/cli/index.html new file mode 100644 index 0000000..fc0599c --- /dev/null +++ b/category/cli/index.html @@ -0,0 +1,524 @@ + + + + + + + + + + + + + + + + + + + + + + + cli - yap + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + Skip to content + + +
    +
    + +
    + + + + + + +
    + + +
    + +
    + + + + + + +
    +
    + + + +
    +
    +
    + + + + + +
    +
    +
    + + + +
    +
    +
    + + + +
    +
    +
    + + + +
    +
    +
    +

    cli

    +
    + + + + + + + + + + + + +
    +
    + + + +
    + +
    + + + +
    +
    +
    +
    + + + + + + + + + + \ No newline at end of file diff --git a/category/linux/index.html b/category/linux/index.html new file mode 100644 index 0000000..05bf402 --- /dev/null +++ b/category/linux/index.html @@ -0,0 +1,524 @@ + + + + + + + + + + + + + + + + + + + + + + + linux - yap + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + Skip to content + + +
    +
    + +
    + + + + + + +
    + + +
    + +
    + + + + + + +
    +
    + + + +
    +
    +
    + + + + + +
    +
    +
    + + + +
    +
    +
    + + + +
    +
    +
    + + + +
    +
    +
    +

    linux

    +
    + + + + + + + + + + + + +
    +
    + + + +
    + +
    + + + +
    +
    +
    +
    + + + + + + + + + + \ No newline at end of file diff --git a/category/shell/index.html b/category/shell/index.html new file mode 100644 index 0000000..f750a55 --- /dev/null +++ b/category/shell/index.html @@ -0,0 +1,524 @@ + + + + + + + + + + + + + + + + + + + + + + + shell - yap + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + Skip to content + + +
    +
    + +
    + + + + + + +
    + + +
    + +
    + + + + + + +
    +
    + + + +
    +
    +
    + + + + + +
    +
    +
    + + + +
    +
    +
    + + + +
    +
    +
    + + + +
    +
    +
    +

    shell

    +
    + + + + + + + + + + + + +
    +
    + + + +
    + +
    + + + +
    +
    +
    +
    + + + + + + + + + + \ No newline at end of file diff --git a/index.html b/index.html index a03ae61..16169cf 100644 --- a/index.html +++ b/index.html @@ -10,6 +10,8 @@ + + @@ -212,19 +214,175 @@ -
  • - + + + + +
  • + + + + + + + + + +
  • + + + + + + + + + + + + + +
  • + + + + + + + + + + +
  • + + @@ -257,6 +415,58 @@

    well, i yap here

    +
    +
    + + +
    +
    +

    Linux How-TOs ❓ | A must know list of commands in Linux shells

    +

    Hello Everyone 👋.

    +

    Here's a list of useful tools and commands that are required often for using Linux as a daily driver or even only for development.

    + + + + +
    +
    + + + + + + + + +