Skip to content

[Tutorial] Basic Terminal Commands

August Zhang edited this page Dec 20, 2021 · 7 revisions

Terminal is the soul of GNU/Linux

Yes, the terminal may look like something only a hacker use. However, it is the quintessential element for any GNU/Linux operating system. Here is a short introduction for newcomers to JingOS and GNU/Linux. Happy tinkering!

The Structure of Commands

To start with, there is some nitty-gritty you need to know. A shell is like the nobs on a machine that allows you to interact with the computer. For most GNU/Linux based OSs, Bash is the default shell. This is a typical command of the Bash shell. user_name@DEVICE_NAME:~$ <COMMANDS>

File Structure and Superuser Privilege

In Linux, everything is a file including the ones of the OS. To protect the OS from being damaged, you need to acquire the superuser privilege to access the system files, including installing and uninstalling an app. If you wish to gain superuser privilege, you need to use "sudo". The terminal will prompt you to input the password, which is the one you set the first time you start the device. For example, if you want to install an app, let's say "gimp", using "apt" package manager, you can input this command sudo apt-get install gimp

Directory

A directory is shown as a "folder". Please note, the label of a directory is case sensitive. Here are some common commands for printing and manipulating the directories.

  • pwd is to print the current directory.
  • ls is to list the items in a directory (files or subdirectories)
  • cd is to change the directory.
  • mkdir is to create (make) a directory If you are in the 'Home' directory now, and the directory tree is like the following:

./Home

./Home/Desktop

./Home/A_Sub_Dir_in_Desktop

./Home/Download

./Home/User

If you want to print the current directory, you can input pwd. Now, let's see what will be shown by your Terminal

Input: user_name@DEVICE_NAME:/Home$ pwd

Result: ./Home

If you want to list the items in the directory, use ls

Input: user_name@DEVICE_NAME:/Home$ ls

Result: Desktop Download User

If you want to change the directory to Desktop, use cd

Input: user_name@DEVICE_NAME:/Home$ cd Desktop

Result: user_name@DEVICE_NAME:/Home/Desktop$ To change back to the parent directory, use cd .. (There's a white place between cd and ..)

If you want to create a subdirectory (a folder), say "Music", under the Desktop directory, change the working directory to Desktop, then use mkdir

Input: user_name@DEVICE_NAME:/Home/Desktop$ mkdir Music To remove the folder "Music", use rm Music -r

Final Words

Now you have some ideas of how the terminal works. Be careful not to tinker with the system files if you don't know what you are doing. If you still have problems, please join our community Telegram

Read More:

Ubuntu Guide for Linux

To learn Terminal with Terminal Quest