Skip to main content

Ubuntu has been my main operating system for over a year now. Though it may not be my main choice, for very superficial reason, I’ve come to warm up to it when it comes to development.

Linux operates on commands… super convenient especially when you know which commands do what.

Anyway, here are some commands I have found myself using almost everyday I’m working with Ubuntu.

  1. sudo

This is first and most important command. Any command that needs root permission is preceded by this command.

2.ls

This is used when you want to see what is in a directory. It displays the content of the directory you are currently working in. (It also basically means list)

3.mkdir

This command creates a directory or folder. It is followed by the name intended for the new folder.

4. rm

The rm command deletes a file or a folder. You have to specify the name of the file/ folder after the rm command.

rm newdocument.txt 

5. apt-get

The apt-get command installs, upgrades and removes any software.

apt-get update
apt-get install 'software-name'

apt-get remove 'package-name'

6. cd

cd command changes into or out of a directory. For instance to leave a directory `cd ..` while to get into one

`cd [directory name/path]`

7. cp

cp allows a user to run copy-paste a file. First identify the file you want to copy then the destination it will be pasted in.

`cp [file-to-copy] [file-to-paste]` 

8. grep

Sometimes you can’t remember the exact location of a file. The grep command makes it easier to find this file based on keywords provided.

`grep ['keyword']`

9. poweroff

From its name, this commands shuts down your computer. Include the command `sudo` at the beginning for root permission.

10. cat

cat displays the text inside a file.

11. mv

This command changes the location of a file or renames it.

To rename:

 `mv [filename]  [new file name]` 

To change location:

`mv [filename] [path to destination]` 

12. chmod

This command changes the permissions of files. This can be done only by the file owner or a privileged user.

`chmod option permissions filename`

Owners include: User (u), Group(g) and Others(o)

Permissions include: Read(r)or(4), Write(w)or(2), Execute(x)or(1), No Permission(0)

To make it less complex, say you want to change the permissions of a file for the user to read, write and execute; members of your group to read and execute; and other to only read.

The command would look like this:

`chmod
u=rwx, g=rx, o=r myfile`

13. exit

Terminates or ends a script and goes back to the original script.

14. kill

Shuts down process. Usually done by the admin.

15. lsof

Lists all open files.

16. netstat

Provides information about protocols in use and current TCP/IP network connection.

17. pwd

Displays the name of the current working directory.

18. ps

Displays the status of current processes in the system.

19. gzip

Compresses and decompresses files.

To compress :

`gzip filename`

To decompress:

 `gzip -d filename.odt.gz`

20. chown

Changes user and group ownership of a file.

`chown [user name of new owner] [target file]`