100 Essential Ubuntu Terminal Commands for Beginners

100 Essential Ubuntu Terminal Commands for Beginners

The Linux command line is a powerful tool that can be used to manage your system, automate tasks, and troubleshoot problems. While it can be intimidating at first, learning the basics of the command line is well worth the effort.

In this blog post, we will introduce you to 100 essential Ubuntu terminal commands that every beginner should know. These commands will cover a variety of topics, including navigating the filesystem, manipulating files, and managing processes.

We will also provide examples of how you can use these commands to accomplish common tasks. By the end of this post, you will have a solid foundation in the Linux command line and be well on your way to becoming a power user!

Navigating the Filesystem

The filesystem is a hierarchical structure of directories and files that stores all of the data on your computer. The root directory is the top-level directory, and all other directories and files are located below it.

To navigate the filesystem, you can use the cd command. The syntax for the cd command is:

cd directory
For example, to change to the Documents directory, you would type:

cd Documents

You can also use the ls command to list the contents of a directory. The syntax for the ls command is:

 

ls
For example, to list the contents of the Documents directory, you would type:

 
ls Documents

 

Manipulating Files

You can use the Ubuntu terminal to create, delete, and modify files. To create a new file, use the touch command. The syntax for the touch command is:

touch filename
For example, to create a new file called “my_file.txt”, you would type:

touch my_file.txt

To delete a file, use the rm command. The syntax for the rm command is:

rm filename
For example, to delete the file “my_file.txt”, you would type:

rm my_file.txt

To modify a file, use any text editor that you are comfortable with. Once you have made your changes, save the file and exit the text editor.

Managing Processes

The Ubuntu terminal allows you to view, start, stop, and kill processes. To view all of the processes that are currently running on your computer, use the ps command. The syntax for the ps command is:

ps
To start a new process, use the bash command. The syntax for the bash command is:

bash
To stop a process, use the kill command. The syntax for the kill command is:

kill process_id
For example, to stop the process with the process ID of 1234, you would type:

kill 1234

To kill all processes that are owned by a particular user, use the killall command. The syntax for the killall command is:

 

killall username

For example, to kill all processes that are owned by the user “johndoe”, you would type:

 

killall johndoe

 

General Commands:

  • man: Displays the manual page for a command. Example: man ls – displays the manual page for the “ls” command.
  • help: Displays help for a command. Example: help cd – displays help for the “cd” command.
  • exit: Exits the terminal. Example: exit – exits the terminal.
  • history: Displays a list of the commands that you have recently entered. Example: history – displays the list of recently entered commands.
  • clear: Clears the terminal screen. Example: clear – clears the terminal screen.
  • pwd: Displays the current working directory. Example: pwd – displays the current working directory.

Directory Management:

  • mkdir: Creates a new directory. Example: mkdir my_directory – creates a new directory called “my_directory”.
  • rmdir: Removes an empty directory. Example: rmdir my_directory – removes the empty directory called “my_directory”.

File Management:

  • cp: Copies a file or directory. Example: cp file.txt /path/to/new/location/ – copies the file.txt to the specified location.
  • mv: Moves a file or directory. Example: mv file.txt /path/to/new/location/ – moves the file.txt to the specified location.
  • rm: Removes a file or directory. Example: rm file.txt – removes the file.txt.
  • touch: Creates an empty file. Example: touch new_file.txt – creates a new empty file called “new_file.txt”.
  • ln: Creates a symbolic link to a file or directory. Example: ln -s /path/to/original /path/to/link – creates a symbolic link to the original file/directory.

File Viewing:

  • cat: Displays the contents of a file. Example: cat file.txt – displays the contents of file.txt.
  • more: Displays the contents of a file one page at a time. Example: more file.txt – displays the contents of file.txt one page at a time.
  • less: Displays the contents of a file one page at a time, allowing you to scroll up and down. Example: less file.txt – displays the contents of file.txt one page at a time with scrolling ability.
  • head: Displays the first few lines of a file. Example: head file.txt – displays the first few lines of file.txt.
  • tail: Displays the last few lines of a file. Example: tail file.txt – displays the last few lines of file.txt.

File Searching:

  • grep: Searches for a pattern in a file or set of files. Example: grep "pattern" file.txt – searches for the specified pattern in file.txt.
  • egrep: Searches for a pattern in a file or set of files, using extended regular expressions. Example: egrep "pattern1|pattern2" file.txt – searches for multiple patterns in file.txt.
  • find: Searches for files that match certain criteria. Example: find /path/to/search -name "*.txt" – searches for all files with .txt extension in the specified path.

System Management:

  • sort: Sorts the lines of a file. Example: sort file.txt – sorts the lines of file.txt alphabet

Conclusion

These are just a few of the many essential Ubuntu terminal commands that you should know. By learning these commands, you will be able to use the Linux command line to manage your system, automate tasks, and troubleshoot problems.

Share this post

Leave a Reply

Your email address will not be published. Required fields are marked *