Introduction
Created by Christopher Lawrence GS '24
Greetings and welcome back to the command line tutorial. Today we will be covering how to: move within your computers cyberspace, find files, move files, rename files, and create and delete folders. Lets dive right in!
To access a specific folder on your computer, you might double click on a folder using the mouse. For example:
From the command line, we do not have that option. But it is just as viable and maybe even quicker to use the command line to access files and folders, and files within folders within folders......
Download and unpack the following folder to your desktop.
StudioLab.zip
This folder contains all the files needed for today's tutorial. Make sure to place it on your Desktop.
cd
You saw this command briefly in the last tutorial. cd stands for change directory. This command allows you to move up and down the file tree within your computer. Here's an example of the file tree. Showing the path to the folder, you just placed on your desktop, and its contents.
We could peruse these files and folders, and move down the file tree, shown above, using the mouse. Or we could use the command line. Open up the terminal and use the following commands to navigate to the StudioLab folder on your desktop.
pwd (#to show the current directory)
cd Desktop
cd Studiolab
ls pwd
ls resources
If we know the "path" to the file or folder, we do not need to sequentially type the cd command. Rather we can type the entire path at once, like so
cd ~/Desktop/Studiolab/resources ls
cd can also take us up the file tree
cd ..
pwd
cd ..
pwd
Or if we want to go all the way back to the beginning, without using ".." we can use "$HOME", "~", or just cd alone will do the job. Try these out below.
cd
cd ~
cd $HOME
To view the current working directory we can use pwd from before.
While working on a computer, it is very easy to forget the locations of files and folders. Especially, if you don't use them everyday or they hold sentimental value to you. Normally, we would use a search bar to find a file on our computer.
But, the command line has a command for that too!
find
find can be used to search your computer for a file.
find -name neverforget.jpg
To exit, Hold down the control key, then hit the C button.
mv
Once we have found the file, we might desire to rename it. For that we can use mv (move) to rename files.
We might also desire to move it somewhere new. To do so we also use mv!
mv file.txt filea.txt
mv filea.txt ~/Desktop/StudioLab
cd .. ls
mv is very capable and powerful. Make sure to wield this power carefully, as you could potentially overwrite an entire folder.
It has happened to me before...so.............BEWARE.........
mkdir
If we want to make a new directory, we use the mkdir command. This command stands for, well, ....... make directory.
mkdir Notion_files
rm
Finally, to remove files we will use the rm command. To remove directories we use the rmdir command.
cd Desktop
rm filea.txt
rmdir Notion_files
rmdir StudioLab (Doesnt work for directory with contents)
rm -r StudioLab
Once again, use this with caution!
This completes this part of the tutorial!
In the next tutorial we will learn how to test our internet connection, view the jobs and processes our computer uses, and some command line magic, that will make you look like a pro in front of your friends. See you there.