Lists of Basic Linux Commands for Bash

Linux

Linux

Linux has been commonly run almost everywhere in technology, such as your desktop, smartphone, router, web server, IoT and even in the stock market.  If you are a web developer, mobile developer, software engineer, hardware engineer or other IT related person, learning Linux can help you have better understanding on collaboration and communication. This article records bunch of lists of basic Linux commands for the beginner needs.

 

Before we started, since Mac and Linux OS already has its own command editor. For Windows user, you can install one of Linux system, or one of desktop environment for Linux.

There also has a beta light version of “bash on Windows” for 64-bit Windows 10 user. Operating system installation guide can be found in HERE.

 

In bash on Windows, the current home directory can be found in:

C:\Users\YourUserName\AppData\Local\lxss\home

This directory is marked as a hidden system folder for a very good reason, so avoid creating and/or modifying files in this location using Windows tools and apps!

 

BASICS:

  • present current working directory
    pwd
  • list all the files
    ls
  • list all the files (include hidden files)
    ls -a
  • list all the files with detail lists(permission, boolean, capacity, updated time)
    ls -l
  • go on the document (Case sensitive, type tab in the middle to detect the folder name)
    cd [folder name]
  • go to the root
    cd /
  • go to home
    cd ~
  • open default text editor (nano or vim). For vim advanced usage. Take a look at Vi Cheat Sheet.
    nano [file name]

    or

    vi [file name]
  • read the first 10 lines in file
    head [yourfile]
  • read the last 10 lines in file
    tail [yourfile]
  • read the content in file
    cat [yourfile]
  • Insert some text into file.
    echo "Hello World!" >> [your file]
  • Insert some text into file and overwrite it. (use it carefully!)
    echo "Hello World!" > [your file]

 

FILE OPERATIONS:

  • delete files
    rm [file name]
  • remove directory
    rm [file folder]
  • remove directory that has files (be careful!)
    rm -R [file folder]
  • remove directory
    rmdir [your folder name]
  • remove file
    rm [your file name]
  • make directory
    mkdir [your folder name]
  • move your file (like cut)
    mv [file name] [file directory or file folder name]
  • rename your file
    mv [file name] [different file name]
  • copy your file
    cp [file name] [file directory or file folder name or different file name]
  • find/search your file by name
    find [file directory] -name [file name]

    like

    find [where-to-look] [criteria] [what-to-do]

 

SUDO & USER PERMISSION:

  • If permission denied, try to add this before all commands. (run as super user administrator)
    sudo

    or

    su
  • By default, the superuser (root) account is disabled and doesn’t have any password. You can create one by running:
    sudo passwd root
  • add a new user
    useradd -m -g users [user name]
  • remove home user folder
    rm -rf /home/[user folder]
  • Give the folder store and all files and folders within the store folder all permissions. (Read -4, write -2, exec -1)
    chmod 777 [your folder]

 

OTHERS:

  • Viewing all the configurations. (usually use for wifi and network interface)
    ifconfig -a
  • clear your terminal interface
    clear
  • terminal any process (be careful it might close your entire sever, like docker, your should use ctrl+p+q instead of below code)
    ^ C (ctrl+c)

 

For more Linux usage, I create a YouTube lists in HERE. Wish you enjoy your learning process and have a nice day 🙂

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *