Raspberry Pi Raspbian Essential Commands


The command-line interface was a great step up from manually toggling in user's instructions in octal (base-8), using switches on the front of the machine. Graphical user interfaces brought friendly visual metaphor to the computer, losing some power and expressiveness. With the Pi, user can get the best of both worlds by knowing both.

<img src="rasp.png" alt="rasp">


<Ctrl><Alt><F1>
Switch to the first text terminal. Under Raspbian user can have several (6 in standard setup) terminals opened at the same time.

<Ctrl><Alt><Fn> (n = 1 up to 6)
Switch to the n-th text terminal.

<Ctrl><Alt><F7>
Switch to the first GUI terminal.

<Ctrl><Alt><Fn> (n = 7 up to 12)
Switch to the n-th GUI terminal. On default, nothing is running on terminals 8 to 12.

<Tab>
In a text terminal, autocomplete the command if there is only one option, or else show all the available options.

<ArrowUp>
Scroll and edit the command history. Press <Enter> to execute.

<Shift><PgUp>
Scroll terminal output up. Work also at the login prompt, so user can scroll through your bootup messages.

<Shift><PgDown>
Scroll terminal output down.

<Ctrl><Alt><BkSpc>
In X-windows, kill the current X-windows server. Use if the X-windows server crushes and cannot be exited normally.

<Ctrl><Alt><Del>
Shut down the system and reboot. This is the normal shutdown command for a user at the text-mode console. Don't just press the "reset" button for shutdown!

<Ctrl>c
Kill the current process, mostly in the text mode for small applications.

<Ctrl>d
Log out from the current terminal.

<Ctrl>s
Stop the transfer to the terminal.

<Ctrl>q
Resume the transfer to the terminal. Try if terminal mysteriously stops responding.

<Ctrl>z
Send the current process to the background.

exit
Logout.

reset
Restore a screwed-up terminal to default setting.

~ (tilde)
Home directory, for example, the command cd ~/my_dir will change working directory to the subdirectory "my_dir" under home directory.

. (dot)
Current directory, for example, ./my_program will attempt to execute the file "my_program" located in current working directory.

.. (two dots)
Directory parent to the current one, for example, the command cd .. will change current working directory one one level up.

tty
Print the name of the terminal in which user are typing this command.

ls
List the content of the current directory. Under Linux (Raspbian), the command "dir" is an alias to ls.

ls -al |more
List the content of the current directory, all files (also those starting with a dot), and in a long form. Pipe the output through the "more" command, so that the display pauses after each screenful.

cd "directory"
Change directory. Using "cd" without the directory name will take user to home directory, "cd -" will take user to previous directory and is a convenient way to toggle between two directories, "cd .." will take user one directory up.

mkdir "directory"
Make a new directory.

rmdir "directory"
Remove an empty directory.

cp "source destination"
Copy files. Use the "-r" option (for recursive) to copy the contents of whole directories.

startx
Start an X-windows server and the default windows manager.

pwd
Print working directory.

hostname
Print the name of the local host.

whoami
Print login name.

id "username"
Print user id (UID), group id (GID), effective id, and the supplementary groups.

date
Print or change the operating system date and time. For example to change the date and time to 2015-12-31 23:57 using this command: date 123123572015

time
Determine the amount of time that it takes for a process to complete plus other info.

who
Determine the users logged on the machine.

rwho -a (remote who)
Determine all users logged on network. The rwho service must be enabled for this command to run. If it isn't, run setup as root to enable "rwho".

last
Show listing of users last logged-in on system.

history | more
Show the last (1000 or so) commands executed from the command line on the current account. The "| more" causes the display to stop after each screenful.

uptime
Show the amount of time since the last reboot.

ps (print status)
List the processes currently run by the current user.

ps axu | more
List all the processes currently running, even those without the controlling terminal, together with the name of the user that owns each process.

Commands are not cryptic (at least not intentionally) but they are terse.