Use the command line to manipulate the local filesystem.
- Familiarize yourself with the command line.
- Obtain access to a personal computer with either Windows or Mac OS.
See the following operating system-specific guides in separate files, below.
Use the command line to manipulate the local filesystem.
See the following operating system-specific guides in separate files, below.
Open the Terminal application.
Print the current user's name.
whoamiPrint the current/present working directory.
pwdList files in the current working directory.
ls
ls -al # for a different displayChange directories (specifying absolute file path).
cd ~/DesktopMake a new directory.
mkdir my_folderRemove a directory.
rm my_folder # triggers an error
rm -rf my_folder # recursively (-r) forces (-f) removalChange directories (using relative file path).
cd my_folder # first re-create this directory if it doesn't exist, else this will trigger an errorCreate a file.
touch README.md
touch index.html
touch my_data.csv
touch my_message.txtRemove a file.
rm index.htmlEdit and save a file, using a text editor like notepad.
Print file contents.
cat my_message.txtMove a file.
mv ~/Desktop/my_folder/my_message.txt ~/DesktopCopy a file.
cp ~/Desktop/my_message.txt ~/Desktop/my_folderCopy contents of a file into the clipboard for pasting.
pbcopy < ~/Desktop/my_folder/my_message.txt
# ... then just paste as you normally would after copying some textThere are many other utilities to use from the command-line.
Make your computer speak:
say "Hello, I am your computer. Let's be friends."Trace the route traveled by a network request:
traceroute google.com
# ... stop after a few seconds if necessary by pressing: control + cTime the duration of a network request:
ping google.com
# ... stop after a few seconds if necessary by pressing: control + cRequest the contents of a webpage:
curl google.com
curl http://www.google.com
curl http://hypem.com/playlist/popular/3day/json/1/data.js
curl https://raw.githubusercontent.com/debate-watch/twenty_sixteen/master/lib/twenty_sixteen/candidates.jsonOpen the Command Prompt application.
Print the current user's name.
whoamiPrint the current/present working directory.
cdList files in the current working directory.
dirChange directories (specifying absolute file path).
cd C:\Users\YOUR_USERNAME\Desktop\ # where YOUR_USERNAME is the name of the user currently operating your local machineMake a new directory.
mkdir my_folderRemove a directory.
rmdir my_folderChange directories (using relative file path).
cd my_folder # first re-create this directory if it doesn't exist, else this will trigger an errorCreate a file.
type nul > README.md
type nul > index.html
type nul > my_data.csv
type nul > my_message.txtRemove/delete a file.
del index.htmlEdit and save a file, using a text editor like notepad or notepad++.
Print file contents.
type my_message.txtMove a file to target location.
move C:\Users\YOUR_USERNAME\Desktop\my_folder\my_message.txt C:\Users\YOUR_USERNAME\DesktopCopy a file.
xcopy C:\Users\YOUR_USERNAME\Desktop\my_message.txt C:\Users\YOUR_USERNAME\Desktop\my_folderCopy contents of a file into the clipboard for pasting.
type C:\Users\YOUR_USERNAME\Desktop\my_folder\my_message.txt | clip
# ... then just paste as you normally would after copying some textTrace the route traveled by a network request:
tracert google.com # stop after a few seconds if necessary by pressing: control + cTime the duration of a network request:
ping google.com # stop after a few seconds if necessary by pressing: control + c