Skip to main content

Terminal & Common Commands

  • Video Tutorial


Opening Terminal in Desktop System

The Terminal dates back to the early days of computing, when there were no visual desktops and many computer operations were performed through terminal commands. Even today, we use terminals in many scenarios and for debugging. Mastering common Linux terminal commands can make your development work much more efficient. (The non-desktop system only displays this terminal after booting.)

Click the third item "Terminal" in the Launch Bar to open the terminal. Items are: Browser, File Manager, Terminal

terminal

The first thing you see in the terminal is the prompt, waiting for your instructions. The prompt appears as follows:

pi@WalnutPi:~$

pi indicates the username;

@ followed by WalnutPi indicates the hostname;

~ indicates the current directory;

$ indicates a non-privileged user.

Let's do a simple terminal test. Enter ls in the terminal and press Enter. You will see a listing of files and folder names in the current directory (the non-desktop system has no files in the pi directory by default):

ls

ls

Enter cd Desktop and press Enter. You will see the prompt change, indicating the current directory is now Desktop.

cd Desktop

cd

Opening Terminal via Debug Serial Port

Connect to the computer using a USB-to-TTL adapter via the serial terminal header pins reserved on the WalnutPi, then log in using terminal software such as PuTTY:

Note

When the system fails to boot normally, you can use this feature to observe boot messages. Note that TX and RX are cross-wired, and USB TTL tools with voltage switching functionality must be set to 3.3V.

debug1

Note

If you are using a ZeroW, you can connect via the expansion board's debug serial port, or modify the config.txt file to change the debug serial port number, enabling terminal output via uart2 on the 40-pin header. config.txt Debug Serial Port Settings Tutorial

In Device Manager, you can see the device's COM port number:

debug2

Open PuTTY:

debug3

Enter the COM port number you found for your computer, set the baud rate to 115200, and click Open:

debug4

Then a username and password prompt will appear. Enter "pi" for both the regular user account and password. If nothing appears, try pressing the Enter key. After successful login, the WalnutPi terminal information will be displayed.

debug5

User Switching

The WalnutPi system has 2 preset users:

  • Regular Account (default for desktop system) Username: pi Password: pi
  • Administrator Username: root Password: root

Some terminal commands require administrator privileges to execute. You can run them using sudo + command in the terminal. To directly switch to the administrator account in the terminal, use the su command.

Switch to administrator: Enter su in the terminal, press Enter, and then at the Password: prompt enter the password root (the password is not displayed, mind the case). Press Enter again, and the current terminal session will switch to the administrator user.

su

usr1

Switch to regular user: Enter su followed by the username and press Enter. For example, to switch to the pi user, enter:

su pi

usr2

Common Linux Commands

No.CommandFull NameFunction
1lslistList files in the current directory
2pwdprint working directoryOutput current directory
3cdchange directoryChange directory
4mkdirmake directoryCreate a new directory
5catconcatenateDisplay or concatenate file contents
6rmremoveDelete files
7rmdirremove directoryDelete directories
8mvmoveMove/rename files or directories
9cpcopyCopy files or directories
10echoDisplay input content in terminal
11dateRead system date and time
12grepglobal search regular
expression and print
Search regular expressions comprehensively and print
13manmanualDisplay command manual
14sudosuper user doExecute with root privileges
15chmodchange modeChange file read/write permissions
16./programRun the program
17aptadvance package toolInstall/remove software packages
18exitExit
19rebootRestart
20poweroffShutdown