Command Line
Linux Commands
Terminal
A screen window that gives you access to the command-line interface.
(e.g. LXTerminal)
Command-line Interface (CLI)
Allows you to communicate with a computer using text commands.
Graphical LXTerminal
Graphical LXTerminal
Graphical LXTerminal
Graphical LXTerminal
username
Username that you used to log in.
Graphical LXTerminal
username
hostname
Hostname of your device,
can be identified on a network.
Graphical LXTerminal
username
hostname
The current directory,
represented by the ~ (tilde) symbol.
This is a referal to your home directory: /home/pi
directory
Graphical LXTerminal
username
hostname
The prompt to enter a text command,
represented by the $ symbol.
directory
prompt
Directories = Folders
commands | Description |
---|---|
cat | Displays the contents (catalog) of the text file. |
cd | Change directory. For example, the command cd Desktop moves you into the Desktop directory. |
cd .. | Moves you up the directory tree to the parent directory. |
cp | Makes another copy of the file. |
clear | Allows you to clear the terminal. |
date | Displays the time and date. |
ls | Displays a list of files and folders in the current directory. |
ls -l | Provides a list that includes more detail about the files. The -l parameter is a lowercase L (for long), not the numeral 1. |
man | Displays the manual or description file for the command. |
mv | Moves a file to a new location. |
mkdir | Makes a new directory. |
nano | Opens the nano text editor. To open a specific text file, add the file name; for example, nano hello opens the hello text file. |
pwd | Prints the working directory (shows in which directory you are currently working in). |
rm abc | Deletes (removes) the file named abc. |
rmdir | Deletes (removes) a directory. |
startx | Launches the Raspbian desktop interface (GUI). |
Command | Description |
---|---|
sudo | Gives the user root or super user permissions. |
sudo apt-get install abc | Tells the Raspberry Pi to use the Internet to find, download, and install the application called abc. |
sudo apt-get update | Downloads information about any new versions available for applications on your Raspberry Pi. |
sudo apt-get upgrade | Installs available upgrades for all applications on your Raspberry Pi. |
sudo shutdown -h now | Shuts down (halts) the power to the Raspberry Pi. |
sudo shutdown -r now | Shuts down the power to the Raspberry Pi and then restarts it. |
Resources:
- Learn the Command Line
Codecademy.com
@ https://www.codecademy.com/learn/learn-the-command-line
- Conquer the Command Line
The MagPi Essensials eBook
@ https://www.raspberrypi.org/magpi/issues/essentials-bash-vol1/
- Command Line Crash Course
by Zed Shaw
@ https://learnpythonthehardway.org/book/appendixa.html
pwd
print working directory
ls
list content of directory
cd
change directory
cd ~
return to home directory
mkdir
make a new directory
nano
create and edit a file
touch
create a new empty file
rmdir
remove (delete) an empty directory
cp
copy a file
mv
move a file
less
view content of a file
Managing Files and Directories
Type the following commands into the LXTerminal window. Explain each step:
- pwd
- cd to desktop
- ls
- touch hello
- leafpad hello
- rm hello
- cd ..
Managing Files and Directories
Type the following commands into the LXTerminal window. Explain each step:
- pwd [ print working directory ]
- cd Desktop [ change directory to Desktop ]
- ls [ listing what is in current directory ]
- touch hello [ create a file called hello ]
- leafpad hello [ opens file hello in text editor leafpad ]
- rm hello [ removes file hello ]
- cd .. [ changes directory back up ]
Editing Files using nano text editor
Create and edit a text file in the LXTerminal window:
- create a text file on the desktop.
- edit the text file in the text editor.
- exit text editor.
- check if text file is listed in chosen directory.
Create, Edit, and Move Files and Folders
In the LXTerminal window:
- create a directory called PiFu in your pi directory.
- create 2 new directories (a and b) in your PiFu directory.
- create 2 files (one and two) in first directory (a).
- edit files using nano.
- create 1 directory (f) in first directory (a).
- create 1 file in directory (f).
- create 3 files (three, four and five) in second directory (b).
- edit files using nano.
- move file (one) from directory (a) to directory (b).
- move file (four) from directory (b) to directory (a).
- move directory (f) to your pi directory.
Command Line
By zoidbergs
Command Line
- 681