You are on page 1of 2

==========================

Linux Commands Tutorial


==========================
1. listing the files
ls -lth
2. find the disk file system
df -h
3. creating a directory
mkdir testing
4. creating a directory structure
mkdir -p testing_dir/inner_dir/my_files
5. removing a file
rm file_name
6. removing a directory
rm -rf testing_dir
7. viewing current working directory
pwd
8. navigating to another directory
cd testing_dir
cd testing_dir/inner_dir/my_files
9. navigating to the current user's home directory
cd and hit enter
or
cd ~
10. clearing the terminal windows
clear
11. copying a file to another location
cp my_file testing_dir/inner_dir/my_files
12. copying a directory to another location
cp -R my_dir /testing_dir/inner_dir/my_files
13. display the size of any directory
du -chs *
or
du -chs testing_dir
14. show the information about any variable
echo $ORACLE_HOME
15. viewing the current data and time
date
16. compressing a file
gzip filename
or
tar -czf filename.tar.gz filename
17. find a file
locate filename
18. Prints the number of lines in a file.
wc -l filename
19. Prints the number of words in a file.
wc -w filename
20. Display the count of bytes of file.
wc -c filename
21. killing a process
kill -9 process_id
22. find a process information
ps -ef | grep PROCESS_NAME
or
ps -ax
23. shows how long system has been running
uptime
24. removes duplicate lines in a file and display unique contents
unique filename
25. counts occurrence of lines in a file
uniq -c filename
26. displays the difference between two files
diff filename 1 filename2
27. extract/uncompress a file
tar -xzvf archive.tar.gz
28. displays top CPU process
top
29. moving a directory to another location
mv my_dir /testing_dir/inner_dir/my_files
30. changing the ownership of a file
chmod entity+permissiontype file_name
chmod u+r filename // add read permission to user(you)
chmod ug+rwx filename // add read write execute permission to user and
group
chmod go-wx filename // remove write and execute permission from group
and other but not to user(you) to access the file
chmod a-rwx filename // remove all the permissions from user, group and
rest of the world
31. unzips the zip file
gunzip file.gz

You might also like