Skip to content

Latest commit

 

History

History
98 lines (78 loc) · 11.3 KB

TerminalCommands.md

File metadata and controls

98 lines (78 loc) · 11.3 KB

Terminal-Shell Commands

Find WiFi Password on Connected Network (Windows)

  1. Run Command Prompt as Administrator
  2. NETSH WLAN SHOW PROFILE
  3. Look up network name of which you want to explore
  4. NETSH WLAN SHOW PROFILE WIFI KEY=CLEAR (WIFI = network name)
  5. Check for 'Key Content' field

General and File Manipulation Commands

Command Use Notes
man Get information or help about a command
ls List directory contents
pwd Path of working directory
cd Change working directory
mv Move file or change name
cp Copy file
mkdir Make directory
rm Remove files and directories
-r: deletes a directory and all of its child directories
echo
env Stands for “environment”, and returns a list of the environment variables for the current user
echo $HOME An environment variable that displays the path of the home directory
sed 's/snow/rain/' forests.txt “stream editor”. Accepts standard input and modifies it, before displaying it as output data
In the expression s/snow/rain/:
s: stands for “substitution”.
snow: the search string, the text to find.
rain: the replacement string, the text to add in place.
sort Takes a filename or standard input and orders each line alphabetically, printing it to standard output
touch Creates a new file inside the working directory. It takes in a file name as an argument, and then creates a new empty file in the current working directory
uniq Takes a filename or standard input and prints out every line, removing any exact duplicates
top View your system’s resource usage and see the processes that are taking up the most system resources. Top displays a list of processes, with the ones using the most CPU at the top.
ps Lists running processes
kill PID Kill a process, given its process ID.
pgrep firefox Given a search term, pgrep returns the process IDs that match it.
pkill firefox or killall firefox The pkill and killall commands can kill a process, given its name. Use either command to kill Firefox:
lsof -t -i:4200 List process ID of applications using port :4200

Rename a File

mv (option) filename1.ext filename2.ext

“filename1.ext” is the original, “old” name of the file, and “filename2.ext” is the new name.

Option Description
-f by overwriting destination file without prompt
-u update - move when source is newer than destination
-v verbose - print source and destination files

Move a File

mv (option) source destination

Copy a File

cp SOURCE DEST
cp SOURCE DIRECTORY
cp SOURCE1 SOURCE2 SOURCE3 SOURCEn DIRECTORY
cp [OPTION] SOURCE DEST
cp [OPTION] SOURCE DIRECTORY

Other Commands

Command Use
ssh Secure login on remote machine
scp Secure file copy from or to machine
find Look for file
cat Output contents of a file
grep Search for a string of text
-r: searches all files in a directory and outputs filenames and lines containing matched results. -R stands for “recursive”
> Takes the standard output of the command on the left, and redirects it to the file on the right
>> Takes the standard output of the command on the left and appends (adds) it to the file on the right
< Takes the standard input from the file on the right and inputs it into the program on the left
| The | takes the standard output of the command on the left, and pipes it as standard input to the command on the right. You can think of this as “command to command” redirection

Editors and publishing

Command Use Notes
vim Text editor Vim

Account Administration

Command Use Notes
chmod Change permissions on files and directories
~/.bash_profile File used to store environment settings. It is commonly called the “bash profile”. When a session starts, it will load the contents of the bash profile before executing commands

References

stanford.edu
github
chmod