Git Product home page Git Product logo

linux-cheat-sheet's Introduction

Linux-cheat-sheet

Click ⭐if you like the project. Pull Request are highly appreciated. Follow me @SudheerJonna for technical updates.

Table of Contents


No. Topic
1 User information
2 File and directory commands
3 File permissions
4 Networking
5 Installing packages
6 Disk usage
7 System and Hardware information
8 Search Files
9 SSH
10 Vi/Vim-commands

User Information

  1. who It is used to get information about currently logged in user on to system

    $ who
    sudheer :0 2019-08-04 01:21 (:0)
    1. whoami: It display the system’s username
    $ whoami
    sudheer
    1. id: It display the user identification information
    $ id
    

    ⬆ Back to Top

File and directory commands

  1. pwd The pwd(Present Working Directory) command is used to print the name of the present/current working directory starting from the root.

    $ pwd
    /home/sj/Desktop/Linux
  2. mkdir The mkdir(make directory) command allows users to create directories or folders.

    $ mkdir ubuntu
    $ ls
    ubuntu

    The option '-p' is used to create multiple directories or parent directories at once.

    $ mkdir -p dir1/dir2/dir3
    $ cd dir1/dir2/dir3
    ~/Desktop/Linux/dir1/dir2/dir3$
  3. rm: The rm(remove) command is used to remove objects such as files, directories, symbolic links etc from the file system.

    1. Remove file: The rm command is used to remove or delete a file
    rm file_name
    1. Remove file forcefully: The rm command with -f option is used for removal of file without prompting for confirmation.
    rm -f filename
    1. Remove directory: The rm command with -r option is used to remove the directory and its contents recursively.
    rm -r myDir
    1. Remove directory forcefully: The rm command with -rf option is used to forcefully remove directory recursively.
    rm -rf myDir
  4. touch: The touch command is is used to create, change and modify timestamps of a file without any content.

    1. Create a new file: You can create a single file at a time using touch command. The file created is an empty file.
    touch file_name
    1. Create multiple files: You can create the multiple numbers of files at the same time.
    touch file1_name file2_name file3_name
    1. Change access time: The touch command with a option is used to change the access time of a file.
    touch -a file_name
    1. Change modification time: The touch command with m option is used to change the modified time.
    touch -m file_name
    1. Use timestamp of other file: The touch command with r option is used to get timestamp of another file.
    touch -r file2 file1

    In the above example, we get the timestamp of file1 for file2. 6. Create file with Specific time: The touch command with 't' option is used to create a file with specified time.

    touch -t 1911010000 file_name
  5. cat: The cat command is used to create single or multiple files, view contain of file, concatenate files and redirect output in terminal or files.

    1. View file contents: You can view contents of a single or more files by mentioning the filenames.
    cat file_name1 file_name2

    ⬆ Back to Top

File permissions

⬆ Back to Top

Networking

⬆ Back to Top

Installing packages

⬆ Back to Top

Disk usage

⬆ Back to Top

System and Hardware information

⬆ Back to Top

Search Files

⬆ Back to Top

SSH

⬆ Back to Top

Vi/Vim-commands

Vi editor is the most popular text editor from the early days of Unix. Whereas Vim(Vi IMproved) is an improved version of vi editor to be used in CLI (command line interface) for mainly text editing tasks in many configuration files. Some of the other alternatives are Elvis, Nvi, Nano, Joe, and Vile. It has two main operation modes,

  1. Command Mode: It allows the entry of commands to manipulate text.
  2. Entry mode(Or Insert mode): It allows typed characters on the keyboard into the current file.

1. Start with Vi Editor

You can create a new file or open an existing file using vi filename command.

 vi <filename_NEW> or <filename_EXISTING> // Create a new file or open an existing file

 Example:
 vi first.txt

Let's see how do you create file, entre the content and leave the CLI by saving the changes.

  1. Create a new file named first.txt
  2. Press i to enter the insert mode
  3. Enter the text "Hello World!"
  4. Save the text and exit by pressing :wq! command
  5. Check the entered text

2. Cursor movement

These commands will be used in Command mode.
Move cursor

You can use arrow keys(left, right, up and down) to move the cursor on the terminal. But you can also other keys for this behavior.

 h        # Move left
 j        # Move down
 k        # Move up
 l        # Move right
Jump one word

These commands used to jump one word at a time

w        # Jump forwards to the start of a word
W        # Jump forwards to the start of a WORD
e        # Jump forwards to the start of a word
E        # Jump forwards to the start of a WORD
b        # Jump backwords to the start of a word
B        # Jump backwords to the start of a WORD
Move to start or end of a line

These commands used to move starting or ending of a line.

^        # Jump to the start of a current line
$        # Jump to the end of a current line

⬆ Back to Top

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.