Linux Terminal Basics

I’ve been forcing myself to work in terminal lately (on this very server in fact) and I’m posting this for my own benefit as well as yours and will likely be adding to it frequently. Enjoy!

To Kill a process:

  • Search for it with “pgrep processname” replacing processname with the name of the process your trying to kill. This will return the process id.
  • Then use “kill pid” replacing pid with the process id number that was returned from the command above.

Listing:

  • “ls” the basic list directory command to show directory contents
  • “ls -la” some extra arguments to easily see permissions on files listed.

Shutdown:

  • “shutdown -h now” The h in this command stands for halt as your bringing the system to a halt when you shutdown.

Restart:

  • “shutdown -r now”

Change Directory:

  • “cd dirname” Just change dirname to the directory you want to go to ie. “/home/username”.
  • Another useful tip to the cd command is pressing the tab key will auto complete the rest of the folder name you have typed as long as you’ve typed enough to make sure it’s the only result. For instance say you have two folders called Apples-Granny_Smith and Apples-Macintosh Typing “cd Apples-G” and then hitting tab will give you “cd Apples-Granny_Smith/” without you having to type the rest.
  • Furthermore in the same example above if you type “cd Apples-” and hit tab it will give you nothing. However if you hit tab twice it will list both folders for you and any other folders that begin with “Apples-” in the name.

Change Group Permissions:

  • “chgrp root filename.doc” Changes the group permissions for the file “filename.doc” to the root group.

Leave a Reply