Linux
Basic Linux Example
Copies files
cp
cp thisfile.txt /home/thisdirectory
Moves files
mv
mv thisfile.txt /home/thisdirectory
Lists files
ls
ls (all information ls –l)
Clears screen
clear
clear
Closes prompt window
exit
exit
Displays or sets date
date
date
Deletes files
rm
rm thisfile.txt
"Echoes" output on the screen
echo
echo this message
Edits files with simple text editor
vi
vi thisfile.txt
Compares the contents of files
diff
diff file1 file2
Finds a string of text in a file
grep
grep this word or phrase thisfile.txt
Formats a diskette
mke2fs (or mformat
/sbin/mke2fs /dev/fd0 (/dev/fd0 is the Linux equivalent of A:)
Displays command help
man
man command
Creates a directory
mkdir
mkdir directory
View a file
less
less thisfile.txt
Renames a file
mv
mv thisfile.txt thatfile.txt[e]
Displays your location in the file system
pwd
pwd
Changes directories with a specified path
(absolute path)
cd pathname
cd /directory/directory
Changes directories with a relative path
cd ..
cd ..
Displays the time
date
date
Shows amount of RAM and use
free
free
add a user to the system
adduser
view all commands starting with x
x then [tab] <beep> [tab]
Make a symbolic link from x to y
ln -s x y
to view all running processes
ps
to terminate process x (x is PID from ps)
kill x
Change file permissions
chmod <permissions> <file>
chmod -R 753 games
Permissions alias weightage read r
4
write
w
2
execute
x
1
In 753, the first 7 (1st letter) represents the permissions to himself, 5 (2nd letter) represents the permissions to group. 3 (3rd letter) represents the permissions to others. Options: -R for whole directory
7=4+2+1 ; 5=4+1; 3=2+1
Change file owner
chown <new owner> <file>
Change file group
chgrp <new group> <file>
Compress/uncompress files/directories
tar
tar -xvf file.tar -- uncompress a file 'file.tar' tar -xzvf file.tar.gz -- uncompress a file 'file.tar.gz' tar -xjvf