Skip to main content

Terminal and Common Commands

Opening Terminal on Desktop Edition

The terminal traces back to the early days of computing when there was no visual desktop, and most computer operations were performed via terminal commands. Even today, we still use terminals in many scenarios and for debugging. Mastering common Linux terminal commands can greatly boost your development efficiency. (The Server edition only displays this terminal after booting.)

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

The first thing you see in the terminal is the prompt, waiting for your input. The prompt looks like this:

pi@WalnutPi:~$

pi indicates the username;

WalnutPi after @ indicates the hostname;

~ indicates the current directory;

$ indicates a non-privileged user.

Let's do a simple terminal test. Type ls and press Enter to see the files and folders listed in the current directory (The Server edition's pi directory has no files by default):

ls

ls

Type cd Desktop and press Enter to see the current directory change to Desktop:

cd Desktop

cd

Opening Terminal via Debug Serial Port

Connect to the Walnut Pi's reserved serial terminal header pins using a USB-to-TTL adapter to your computer, then use terminal software like PuTTY to log in:

The debug serial header pins on the Walnut Pi 2B are labeled T, R, G, corresponding to TXD, RXD, and GND respectively.

Note

You can use this feature to observe boot information when the system fails to boot normally. Note that TX and RX are cross-connected. USB TTL adapters with voltage switching must be set to 3.3V.

debug1

Check the COM port number in Device Manager:

debug2

Open PuTTY:

debug3

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

debug4

You will then see a login prompt. Enter "pi" for both username and password. If nothing appears, try pressing the Enter key. Upon successful login, the Walnut Pi terminal information will appear.

debug5

User Switching

The Walnut Pi system has 2 preset users:

  • Normal User (Desktop Edition Default) Username: pi Password: pi
  • Root Username: root Password: root

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

Switch to root: Type su in the terminal, press Enter, then enter the password root when prompted at Password: (the password will not be displayed; pay attention to case). Press Enter again to switch to the root user.

su

usr1

Switch to a normal user: Type su followed by the username and press Enter. For example, to switch to the pi user:

su pi

usr2

Common Linux Commands

#CommandFull NameFunction
1lslistList files in the current directory
2pwdprint working directoryPrint the 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 the terminal
11dateRead system date and time
12grepglobal search regular
expression and print
Search for a pattern and print matching lines
13manmanualDisplay command manual
14sudosuper user doExecute with root privileges
15chmodchange modeChange file read/write permissions
16./programRun the program executable
17aptadvance package toolInstall/remove software packages
18exitExit
19rebootReboot
20poweroffShutdown