Unix/Linux Command Line Reference |
||||
Moving around in the file system |
Examining Files |
|||
pwd |
Print Working Directory – show what directory you’re in |
file |
Determine the type of a file |
|
ls |
List the contents of a directory |
cat |
Concatenate a file |
|
ls –la |
List the contents of a dir including hidden files |
less |
View text files and paginate them if needed |
|
cd |
Change to your home directory |
Manipulating files and directories |
||
cd /path/ |
Change directory to /path/ |
cp file1 file2 |
Copy filename1 to filename2 |
|
cd .. |
Change directory up one path |
cp –r dir1 dir2 |
Copy directory1 to directory2 |
|
Job management |
mv file1 file2 |
Move or rename file1 to file2 |
||
ps |
Display your current active processes |
rm file |
Remove file1 |
|
jobs |
Show all jobs you have executing |
rm –r dir1 |
Remove directory1 |
|
kill -9 pid |
Terminate the process owned by PID (process identifier) |
rm –rf dir1 |
Remove directory1 (does not need to be empty |
|
killall proc |
Terminate all processes named proc |
rmdir dir1 |
Remove an empty directory |
|
bg |
lists stopped or background jobs; resume a stopped job in the background |
mkdir dir1 |
Make directory1 |
|
fg |
Brings the most recent job to foreground |
touch file1 |
Create an empty file named file1 |
|
Shortcuts |
head file1 |
Show the first 10 lines of a file |
||
Ctrl+C |
Halts the current command |
tail file1 |
List the last 10 lines of a file |
|
Ctrl+Z |
Stops the current command, resume with fg in foreground or bg in background |
Searching |
|
|
Ctrl+W |
Erases one word on the current line |
grep pattern files |
Search for pattern in files |
|
Ctrl+U |
Erases the whole line |
grep -r pattern dir |
Search recusively for pattern in dir |
|
Ctrl+R |
Type to bring up a recent command |
command | grep pattern |
Search for pattern in the output of command |
|
!! |
Repeats the last command |
locate file |
Find all instances of file |
|
exit |
Log out of current session |
File Permissions |
||
System Info |
chmod octal file |
Change the permissions of file to octal, which can be found separately for user, group, and world by adding: 4 (read), 2 (write), 1(execute) |
||
date |
Show the current date and time |
|||
cal |
Shows this month's calendar |
EX:chmod 777 |
read, write, execute for all |
|
man command |
Show the manual for command |
EX:chmod 755 |
RWX for owner, RX for group and world |