Prints path of current directory. (Think: what is the address of the folder I’m viewing?)
pwd
Prints contents of current directory. (What stuff is in the current folder?)
-
-a= all files (include hidden files) -
-l= detailed list
Path to the folder you want to see the contents of (Leave blank to see current folder contents)
ls -al
Move to the specified path. (I want to go somewhere, and I need to tell the terminal where.
Exact path of the folder you want to move to, or just a subdirectory
cd Directory
cd ~/Documents
Permanently deletes a file or folder (No trash/recycling bin!)
-
-r- Delete a folder and its contents -
-f- Stop confirmation prompt for write-protected files
Path to the folder/file you want to delete
rm [TAGS] Path
rm -rf ~/Documents/Junk
Move an existing file somewhere else. It can also be used to rename files.
-
The file you want to move
-
The destination
mv ~/Documents/source/file.txt ~/Documents/destination/file.txt
mv ~/old_name.txt ~/new_name.txt
Copy files or folders to a new location
cp Source Destination
cp File-1 File-2 File-3 ... Destination
cp ~/Documents/source/file.txt ~/Documents/destination/file.txt
cp ~/Desktop/Name.java ~/Desktop/Age.java ~/CS180/Homework_1
Clear the Terminal Screen
$ clear
See what programs are currently running
top
Kill all programs with the specified program_name
killall Program_Name
killall firefox
Creates a new file in the location specified in the argument
The files that are to be created
touch File-1 File-2 File-3 ...
touch ~/Documents/file1.txt ~/CS193/HW2/file2.txt
Creates a new empty directory in the location specified in the argument
The name/location of the directory that is to be created
mkdir directory-name
mkdir Documents/Code
If a path includes files or folders with spaces, either use quotations marks (" ") or a backslash (\) before the space. For example:
~/"My Files"/test.txt
or
~/My\ Files/test.text
-
~- Home Directory -
.- Current Directory -
..- Parent Directory
-
Aliases are set in
~/.bashrc -
Add a line to
~/.bashrcthat looks like:alias <shortcut>=“<command>” -
Save file, tell bash to reload:
$ source ~/.bashrc
Used to include a group of files with smiliar characteristics.
They can be used with nearly any UNIX command.
-
cp ~/Desktop/*.java ~/Documents/Project- This command will copy all
.javafiles found in the Desktop directory into theDocuments/Projectfolder.
- This command will copy all
-
mv ~/Desktop/file* ~/Documents- This command will copy all files that begin with "file" in the name into the
Documentsdirectory.
- This command will copy all files that begin with "file" in the name into the
From Lecture 2, you should have learned about how Vim enables commands by typing colon ":" followed by your command. However, there are some commands you don't want to have to type every time. For example, it's pretty normal to want line numbers whenever you open a file. But having to type :set number every time you run Vim kinda sucks. How can we avoid this?
Your ~/.vimrc (Vim Run Control) file controls what commands will run every time Vim is invoked. You can customize it to your heart's content.
You can disable this at any time within a file by typing :set nonumber within Vim, or by deleting it from your ~/.vimrc and then re-opening Vim again.
As you can imagine, there are thousands of commands you can leverage in your ~/.vimrc file. For a great resource on customization, read this article.
A favorite quote from that article that you should definitely adhere to is:
"Don't put any lines in your vimrc that you don't understand."
For those who are using nano, here is an article about nano customization. Similar to Vim, you add your commands in your ~/.nanorc file.