Files and Folders
Your Computer Is a Filing Cabinet
Section titled “Your Computer Is a Filing Cabinet”Everything on your computer is organized into files (documents, pictures, programs) and folders (containers that hold files and other folders). In the terminal, folders are often called directories — the two words mean the same thing.
Where You Are Right Now
Section titled “Where You Are Right Now”Remember pwd? It shows your current folder:
pwdWhen you first open lash, you start in your home directory. This is your
personal space on the computer. You can always refer to it with the shortcut
~ (the tilde character). So ~/Documents means “the Documents folder inside
my home directory.”
Moving Between Folders
Section titled “Moving Between Folders”The cd command lets you move into a different folder. It stands for “change
directory.”
cd DocumentsNow you are inside the Documents folder. Check with pwd to confirm.
To go back up one level (to the folder that contains your current folder), use two dots:
cd ..To jump straight back to your home directory from anywhere:
cd ~Or simply:
cdTwo Kinds of Paths
Section titled “Two Kinds of Paths”A path is the address of a file or folder. There are two styles:
-
Absolute path — Starts from the very top of your file system, beginning with
/. For example:/home/yourname/Documents/notes.txt. This works no matter where you currently are. -
Relative path — Starts from wherever you are right now. If you are in
/home/yourname, thenDocuments/notes.txtrefers to the same file. It is shorter, but only works from the right starting point.
Think of it like street addresses. An absolute path is the full address including city and country. A relative path is “turn left at the corner” — it only makes sense if you know the starting point.
Looking at Folder Contents
Section titled “Looking at Folder Contents”You already know ls. Here are some useful variations:
ls -lThe -l flag shows a long listing with extra details: file sizes, dates,
and permissions (who is allowed to read or change the file).
ls -aThe -a flag shows all files, including hidden ones. Hidden files start
with a dot (like .bashrc or .lash).
Creating Folders
Section titled “Creating Folders”Make a new folder with mkdir (make directory):
mkdir my-projectsYou can create nested folders in one step:
mkdir -p my-projects/website/imagesThe -p flag means “create parent directories as needed.”
Copying Files
Section titled “Copying Files”Copy a file from one place to another with cp:
cp notes.txt notes-backup.txtThis creates a copy called notes-backup.txt in the same folder. To copy into
a different folder:
cp notes.txt ~/Documents/Moving and Renaming Files
Section titled “Moving and Renaming Files”The mv command moves a file. It also doubles as a rename tool:
mv old-name.txt new-name.txtTo move a file into a different folder:
mv report.txt ~/Documents/Deleting Files and Folders
Section titled “Deleting Files and Folders”Remove a file with rm:
rm unwanted-file.txtRemove an empty folder with rmdir:
rmdir empty-folderTo remove a folder and everything inside it, use rm with the -r flag
(recursive — meaning it goes into every subfolder):
rm -r old-projectBe careful with rm. Deleted files do not go to a trash can. They are
gone for good.
Tab Completion for Paths
Section titled “Tab Completion for Paths”Typing long folder names is tedious. lash has tab completion to help. Start typing a path and press Tab:
cd DocPress Tab, and lash will complete it to cd Documents/ if that is the only
match. If there are multiple possibilities, press Tab twice to see all of them.
This works for files, folders, and commands.
Jumping with z
Section titled “Jumping with z”The z command is one of lash’s nicest features. It learns which folders you
visit most often and lets you jump to them with just a keyword:
z projectsIf you frequently visit /home/yourname/work/projects, lash will take you
there instantly. No need to type the full path. The more you use lash, the
smarter z becomes.
Quick Reference
Section titled “Quick Reference”| Command | What it does |
|---|---|
pwd | Show current folder |
cd folder | Move into a folder |
cd .. | Go up one level |
cd ~ | Go to your home directory |
ls | List files in current folder |
mkdir name | Create a new folder |
cp source dest | Copy a file |
mv source dest | Move or rename a file |
rm file | Delete a file |
rmdir folder | Delete an empty folder |
z keyword | Jump to a frequently visited folder |
Now that you can find your way around, let’s make lash look and feel the way you want.