| Command |
What it does |
Notes |
| File and Directory |
|
|
| ls |
list all files and folders in directory |
|
| ls -l |
list the files with details |
|
| cp file1 file2 |
Copy file 1 to file 2 (file 2 new file) |
|
| mv file1 file2 |
move file1 to file2 |
its a copy then delete source, thats how it really works (Some new methodes change the file index rather than physically moove it) |
| cat > file.txt (hit enter) write the file contnet to terminal, then CTRL+D to close it |
a simple way to create a text file from the prompt |
|
| more file.txt |
Display the contents of the file to the terminal (read to terminal) |
will give you a scroll down ability |
| rm file |
delete a file.... |
|
| df -h |
Displays a short report on disk usage. Shows every hard disk's usage, and displays that drive's system name for an identifier |
Sample Output
| Filesystem |
Size |
|
|
|
|
| /dev/sda3 |
228G |
53G |
164G |
25% |
/ |
| /dev/sdb1 |
668G |
16G |
638G |
3% |
/mysecondhd |
| /dev/sda1 |
99M |
34M |
61M |
36% |
/boot |
| none |
1013M |
0 |
1013M |
0% |
/dev/shm |
The last drive (none) is Shared Memory drive.
sda is the first hard drive (showing 2 partitions aboe, sdb is a second one partition hard drive.
You should probably note that S is for SATA drive (Serial ATA), Paralel ATA drives will show as hda and hdb not sda and sdb
|
| rm -rf ./directory |
Delete directory and all its sub folders |
Very Dangerous, No confirmation, Root user can delete entire disk ! |
| tar --create --verbos --file=myfile.tar directory |
Tar entier directory |
Directory can be a name or a full path, --verbos is to list files that are being added |
| tar -cW M (tar -c -M --tapelength=sizeinkbs --file=disk1.tar alargefile) |
|
Multipart tar to a tape drive for example |
| |
|
|
| tar -xvf myfile.tar |
Extracts all files in myfile.tar to curent directory |
|
| tar cvzf |
|
Tar with GZ compression |
| bzip2 -z -k filename |
Compress the file filename |
z is for compress and k is for do not delete input file |
| Session |
|
|
| logout ctril+d (or exit to quit the login) |
|
|
| passwd |
Change Password |
Old, New, New again |
| hostname |
Show host name |
|
| history |
View user command history |
|
| history | grep logout |
Search history for logout |
|
| whoami |
Displays your username |
|
| who |
list all logged in users |
|
| w |
Lists who is logged in and what they are doing |
|
| last |
List of recent system use |
|
| last ausername |
Display last login for user |
|
| ps |
list the processes in your shell session |
|
| ps -u someusername |
List all user processes |
|
| ps aux |
list all processes and display username |
|
| top |
show a constantly updated list of system processes |
|
| top -d 3 |
Update the list every 3 seconds |
|
| ps aux | grep sbin |
list all processes with referance to sbin in there command |
|
| ps aux | grep 10 |
Display all processes with ids containing the number 10 |
|
| whoami --help |
|
|
| man |
display the manual |
|
| info |
View all info manuals on the system |
|
| info -f infofilename |
Read an info file from curent directory |
|
| chmod -R 0777 dir |
CHMOD directory and all contents to 0777 |
The R stands for recursive, take it out and no longer recursive |
| rpm -qi sendmail |
install sendmail rpm |
just an example |
| |
|
|
| |
|
|
| MySQL |
|
|
| mysqldump --opt -u mysqluser --password="userpass" databasename > file.sql |
Dump mysql Database mentioned to SQL file |
Needs MySQL privilages |
| mysqldump --opt -u mysqluser --password="userpass" --all-databases > file.sql |
Dump all MySql Databases to a file |
Needs MySQL privilages |
| mysql -u username --password="userpass" destinationdatabasename < file.sql |
Restores a database |
|
| mysql -u mysqluser --password="userpassword" < file.sql |
Restore an entier database dump (multiple dbs) |
Nothing behind the < except for the casual ordinary space |
| Finding Out about your computers processor |
LINUX:
cat /proc/cpuinfo
BSD:
dmesg | grep cpu |
|