Linux Terminal Commands 101

February 5, 2013 at 3:23 pm by

1,129 Total Views
Linux

Welcome to the Linux Terminal Command 101. A guide to some simple terminal commands that you may need/use on your terminal session. Below are some of these commands along with a few variables and a brief explanation and some example uses.

Navigation

pwd ……- Present Working Directory that you are currently working in
ls ………- List files/folders in current directory
ls ~ ……- List files/folders in home directory
ls / ……- List files/folders in the root directory
ls -l ….. – List files/folders in a long list
ls -a …..- List all files/folders including hidden (starts with .filename)
ls -S …..- Lists files/folders by size
cd ……..- Change Directory (e.g “cd /home” changes working directory to the home folder
cd .. …..- Changes directory up one level

File/Directory Commands

cp …….- Copies a file (e.g “cp index.html index_backup,html”)
mv ….. – Moves or renames a file (e.g “mv index.html /www/newfolder” or “mv index.html index.old”)
rmdir .. – removes an empty directory/folder
rm …….- removes a file
rm -r .. – removes directories and their contents recursively (e.g a directory that is not empty)
mkdir ..- Create a new directory
chmod – Change the permissions on a file (e.g “chmod +x script.sh” makes this script executable)
* ……..- The Wildcard allows you to type a partial match to a file and will list results with that match (e.g to remove all files with script in the name “rm -f script*”)

System Information Commands

df ……..- Display filesytem disk usage for all mounted partitions (use “df -h” to display in MB and GB)
du ……..- Display disk usage on current directory (use “du -sh” to make output more readable)
free .. ..- Shows the amount of free and used memory (use “free -m” to display in MB and GB)
ip addr – Displays the Ip address of the systems network interfaces
ps -e - Displays all running processes amd their PID’s
top….. – Displays information, running processes and system resources, including CPU, RAM & swap usage and total number of tasks being run. To exit top, press q.

Other Commands

kill ……- Kills a process (e.g kill by process name “kill firefox” or PID “kill 4781″
./ …….- Executes a file in current directory (e.g “./script.sh”)
tar -cf – Creates a compressed tar file (e.g “tar -cf archive.tar script.sh”)
tar -xf – Extracts all files from the tar file (e.g “tar -xf archive.tar”)

Endnote: The majority of these commands have more variables that allow different executions or output. To view a list of these variables for a command you can simply use the man command (e.g “man ls”)

© 2013 techsupportforum.com

Filed under Linux, Software
Tagged .