Command Line Basics Flashcards
What is the $ in the command line?
It is the prompt or command prompt
What is the command line?
A user interface that’s navigated by typing
A way to interact with the computer using text and keywords
The command for the current machine and user name
Windows 10
$ whoami
scratchnsniff\jesse agar
Cloud 9
$ whoami
Ec2-user
Where does just the command cd take you?
What’s the difference between root, home, and user’s home and how do you get to each place
Takes you to user’s home direction (not the home folder)
Same as going
$ cd ~
The directory contains everything.
/home/user (c9 takes you to user when going “home”)
Including the home directory. Every user has their own home directory that contains pictures, music, personal files etc.
Root
cd /
Home
cd /home
User’s Home
cd ~
or
cd
Show files in current directory
$ ls
Show hidden files and folders
Show only hidden files and folders
$ ls -a
$ls -d .*
Show longform info on files and folders
(Shows the following: file mode, number of links, owner name, group name, number of bytes in the file, abbreviated month, day-of-month file was last modified, hour file last modified, minute file last modified, and the pathname)
$ ls -l
l for long form
(l for lots of info)
Show longform info on files and folders but with size in kb, mb, and gb as needed rather than just bytes
$ ls -lh
h for Human readable
Show files and folders by size
$ ls -s
s for size
Show files and folders by date modified
$ ls -t
Show files and folders by reversed (of whatever other flags)
$ ls -r
Create a file or update it’s date.
How do you do multiple files?
$ touch
‘Touch’ a file in memory. Creates files. Updates their ‘modified date’.
For multiple files separate by space
$ touch index.html script.js style.css
Keyword for home directory
Keyword for root directory
Where are they relative to one another
~
/
/home/ec2-user
~ and cd bring you to ec2-user, not home, on C9
Keyword for previous directory
..
Keyword for current directory
.
Can be used as a shortcut to add everything in this directory:
$ git add .
Autocomplete a name in terminal
How does it behave if multiple files have the same common letters?
tab while typing a name
Will complete the directory or filename
It will autocomplete up to the most common letter among the options
If there are no more common letters but multiple options, press tab again and it will show you the options
Display name of the current directory
$ pwd
Rename a file
mv oldfile.txt newfilename.txt
Also how you move a file
Move a file
mv oldfiledirectory.txt newfiledirectory.txt
Also how you rename