Shared Flashcard Set

Details

Basic Terminal Commands (OSX)
Basic Terminal Commands (OSX)
27
Computer Science
Undergraduate 1
02/27/2013

Additional Computer Science Flashcards

 


 

Cards

Term
What two flags most likely show the help info for a command?
Definition
--help
-h
Term
Which command will show another command's manual? Also, how would you use the command at the prompt?
Definition
man use it like so: "man launchd"
Term
What command creates a new file?

Alternatively, you can open what program to edit files, and simply save what you write? (and what happens if it is blank?)
Definition
touch

you can use nano to make a new file, but yo ucan only save it if you write something.
Term
Which command would allow you to do the following?

Every time you enter the command 'ls', the shell actually processes the command 'ls -lah'

Note that this is just one example of how this command can be used.

Also, how would you reverse this command, to restore 'ls' to simply process as 'ls'?
Definition
alias

alias ls='ls -lah'
unalias ls
Term
How would you display a list of your aliases?
which flag would disable all aliases?
Definition
simply type 'alias'

'alias -a' deletes all aliases
Term
What important things are contained in the /bin directory?
Definition
The /bin directory contains the basic commands and applications essential to the system. It contains things like ls, cp, mkdir, bash, etc.
Term
What important things are contained in the /usr/bin directory?
Definition
The usr/bin directory contains commands and applications that are not essential to the system, but still important. This includes things like apt-get and tree.
Term
What important things are contained in the /sbin and /usr/sbin directories?
Definition
These two directories contain critical commands and applications that are typically only needed by sysadmins. They are not needed by regular users.
Term
What important things are contained in the /etc directory?
Definition
The /etc directory acts as a repository for system config files,

think things like:
passwords, startup scripts, and the aforementioned config files...
Term
What important things are contained in the /tmp directory?
Definition
the /tmp directory is important precisely because it is not.
It is the system scratch pad. All users, even daemons, write temporary files to the tmp directory.

It is a great place to practice commands, as the system wipes it regularly (usually on a reboot)
Term
What is the /var directory intended for?
Definition
The /var directory (think "variable directory") is used for files and directories that increase in size over time. It is intended to be the main storage location for things like log files, databases, mailboxes, and websites.
Term
What command show you your current directory? (shows you your current path)
Definition
pwd
Term
When using the ls command, what is the flag for:
1) showing hidden files
2) displaying in a list
3) showing file sizes in Kb, Mb, etc.
Definition
'a' showing hidden files
'l' displaying in a list
'h' showing file sizes in Kb, Mb, etc.
Term
how to compress a single file?
Definition
gzip file-name.txt
Term
How to compress a directory (also specifying the file name) What do the flags do?
Definition

tar -czvf [file_name.tgz] [dirname]

 

-c flag means to create new tar archive

-z flag - gzips (compresses it)

-v flag means to be verbose

-f flag mens to specify output file name. without it, the output would be written to the screen.

Term
How to decompress a gzipped archive? Don't forget that it will overwrite a directory's contents!
Definition
tar -xzvf

-x flag uncarchives it
-z flag - gzips (uncompresses it)
-v flag means to be verbose
-f flag mens to specify output file name. without it, the output would be written to the screen.
Term
What command displays the contents of a directory and its sbdirectories in a branching format?
Definition
tree
Term
What command removes a file and/or directory?

What flag forces deletion of non-empty directories?
Definition
rm

-r - recursive delete
Term
How to copy a file?
(into another filename, into another directory, or into another directory/filename)
Definition
cp
cp copy.txt copy2.txt
cp copy.txt /directory
cp directory/copy2.txt
Term
How to make a directory, and how to make nested directories
Definition
mkdir
mkdir -p a/b/c
Term
Understanding file permissions.
A file has a 10 file permissions settings.
There are 3 sets of 3 settings, and then a lone setting.
What are the 3 sets, what are the 3 settings in those sets, and what is the lone setting for?
Definition
-rwxrwxrwx
- rwx rwx rwx
directory? user group others

r - read permission
w - write/edit permission
x - executeble?
Term

1) Which command copies files securely (encrypting them), and is most often used to send files by ssh. 2) How would you write the command to send a directory to a remote server? 3) How would you specify the port?

 

 

ex: scp -P 6244 Street.Fighter.avi root@192.168.2.10:/media

Definition
1) scp scp- [source] [destination] scp big-file.txt server:/directory 2) scp -r [directory] server:/directory 3) scp -P [port]
Term
which command grants temporary root "#" access (if allowed) for a non-root user?
Definition
sudo -i
Term
Which command starts the GUI from the command line, if the GUI has not been launched?
Definition
startx
Term
How to specify a port when using ssh?
Definition
ssh -p [port number]
Term
Which command moves the cursor to the beginning?
to the end?
Back one word?
Forward one word?
Delete everything to the right?
Definition
Which command moves the cursor to the beginning?
ctrl+a

to the end?
ctrl+e

Back one word?
ESC-b

Forward one word?
ESC-f

Delete everything to the right?
ctrl+k
Term
How to show history of previous commands entered at command line?
What shortcut would let you re-enter one of these old commands without having to retype it? (hint: bang)
Definition
'history' shows command history

! [command # from history]
for example, if history #5 was "cd ~/"
then typing !5 would repeat "cd ~/"
Supporting users have an ad free experience!