# Linux Command Line
# Advanced
For a more advanced guide on Linux and more in depth commands, visit Linux Guide.
# Help
- Manual/Help Page(s)
man [cli command]
- Eg.
man ls
- Eg.
# Files and Directories
- List files in current directory
ls
ls -als
(long form)- Eg.
ls -als *.cpp
- Eg.
- Move/rename files
mv [old name] [new name]
- Eg.
mv assignment1.ccp assignment.cpp
(rename) - Eg.
mv assignment1.cpp ~/Documents/CS135/
(move)
- Eg.
- Copy files
cp [original file] [new file name]
- Eg.
cp assignment1.cpp assignment1_copy.cpp
- Eg.
- Delete files
- There is no way to recover deleted files
rm [filesname]
- Eg.
rm assignment1.cpp
- Eg.
rm -r [directory]
(recurse and delete all files in directory as well as directory)- Eg.
rm -rf ~/Documents/CS135
rmdir [directory]
can be used if directory is empty
- Eg.
- Print current working directory
pwd
- Make directory
mkdir [directory]
- Eg.
mkdir CS135
- Eg.
- Change directory
cd [directory name]
- Eg.
cd CS135
- Eg.
cd ~/Documents/CS135
(full path if directory is not below current path) - Eg.
cd
(Return to home directory. Equivalent tocd ~
) - Eg.
cd ..
(Go up one level in the directory tree)
- Eg.
- Print file contents
cat [filename]
- Eg.
cat assignment1.cpp
- Eg.
# Process Control
- Terminate/suspend current foreground process
- Ctrl + C on keyboard to terminate
- Ctrl + Z to suspend
- Find a process
ps
- Eg.
ps -ef | grep [username]
(Print processes belong to username)
- Eg.
- Logout
- Ctrl + d
logout
# Printing
- Printing in Linux
- Printing to the default printer:
lpr [filename]
- Printing to a different printer:
lpr -P[printername] filename
- Checking your default printer and listing the current print jobs:
lpq
- The first line of the output of
lpq
shows your default printer
- The first line of the output of
- Printing to the default printer:
Note: You can print when logged on remotely from any location so long as you are logged into bobby
, cardiac
, or java
.
Printing in Windows
- All print menus should work. To check your default printer, go to Start -> Printers and Faxes, and see which printer has a check mark.
Printing Quota
All students with CS Accounts receive 100 free pages of printing. Additional pages can be purchased for $0.03 per page in whole dollar amounts (RebelCard not accepted). To purchase additional pages, please visit the System Administrator
# Sending Email
First Log into a UNLV CS Server such as
sally.cs.unlv.edu
. Email from the terminal (command line / shell prompt) can be sent as follows.mail user@domain.edu
- This will prompt for a subject and then you can type the body of the mail.
- Hit ctrl-d to send the mail --
EOT
(end of transmission) will be displayed.
mail user@domain.edu < file.cpp
- Sends
file.cpp
in the body of the email with no subject line
- Sends
mail user@domain.edu,user2@domain.edu < file.cpp
- Same as the above, but sends
file.cpp
to two recipients
- Same as the above, but sends
mail -s "Subject line here" user@domain.edu < file.cpp
- Sends
file.cpp
to a recipient with a subject line
- Sends
Note: The 'from' address on emails sent will be from your username @unlv.nevada.edu; replies to that email will be sent to your RebelMail account.
For more details on using Linux mail
utility, see this page (opens new window).