avatarCoucou Camille

Summary

The website content provides a beginner's guide to essential Ubuntu command-line operations for managing files and directories.

Abstract

The article "Ubuntu Commands for Beginners" offers a concise tutorial for new users of the Ubuntu Linux operating system. It covers ten fundamental tasks, including how to determine the current directory, change directories, create and remove directories, create and edit files, list files with detailed permissions, read file contents, edit files with a text editor, copy or move files, and zip or unzip files. The guide is complemented with visual aids and practical examples to facilitate understanding and application of these commands. Additionally, the author invites readers to explore more of their articles on Python and Cryptocurrency and recommends an AI service for those interested in AI capabilities similar to ChatGPT Plus.

Opinions

  • The author believes that the provided commands are essential for beginners to navigate and manipulate the file system in Ubuntu.
  • The use of images is considered helpful for visualizing the outcomes of command executions.
  • The article is structured to be user-friendly, with clear headings and step-by-step instructions.
  • The author suggests that the commands listed are commonly used, implying their utility in everyday operations.
  • By offering a link to their other articles, the author indicates a belief in the value of their broader body of work.
  • The recommendation of ZAI.chat as a cost-effective alternative to ChatGPT Plus implies the author's endorsement of the service based on its performance and affordability.

Ubuntu Commands for Beginners

Photo by Gabriel Heinzer on Unsplash

Ubuntu is most popular Debian-based distribution of Linux Operating System initially released in 2014. This article summarizes the use of basic commands for 10 common tasks that beginners might find useful.

1. Current Directory 2. Change Directory 3. Create New Directory 4. Remove Directories 5. Create New Files 6. List All Files and Directories 7. Read Files 8. Edit Files (Insert/Save/Quit/…) 9. Copy/Move Files 10. Zip/Unzip Files

1. Current Directory

Get the current working directory using command pwd , abbreviation of “print working directory”, you should see something like /home/user_name

2. Change Directory

One of the most used commands in Ubuntu: cd to change directories.

  • Change to root directory: cd /
  • Change to home directory: cd

After the root directory command is run, the working directory changes from /home/alpha to / and after command cd it changed back to the initial home directory again.

  • Go to the parent directory

There is the special syntax .. that refers to the parent directory, hence cd .. to change to the parent directory

You could also use ../.. , ../../.. and so on if you want to move up through multiple levels of parent directories.

  • Go to a directory in the working directory

Use cd command followed by the directory name. For example, to go from /home to /home/alpha :

3. Create New Directory

To make a directory in the current working directory, use command mkdir . For example, to create a directory my_dir and another directory new under my_dir :

4. Remove Directories

  • Command rmdir or rm -d for removal of empty directories:

The command won’t work on a non-empty directory:

  • To remove non-empty directories: use rm -r to delete all its contents at once

5. Create New Files

  • Create an empty file: > filename or touch filename
  • Create a text file and enter the texts: cat > filename

Press Ctrl + D at the end of the file to store the file.

6. List All Files and Directories

  • Simply listing down all files and directories in working directory: use command ls
  • Listing down detailed information of the files and directories: use ls -al or its common alias ll

The 10 letters at the start of the rows for each files represents its permissions. There are three basic actions you could perform to a file or directory:

  1. Read: listings the contents
  2. Write: change the contents, and creation/deletion of file
  3. Execute: run a program or script; or access files of a folder

The letters drwxrwxrwx has the following meanings:

  • First letter d to indicate whether it is a directory
  • Three sets of rwx corresponding to read, write and execute right for owner, group and other.

So for example, -rw-rw-rw- means the file can be read and written by anyone, but not executable; -rw-r--r-- means the file can be read and written by the user, but only read by the group and anyone else.

7. Read Files

  • head filename to get the first 10 lines of a text file
  • tail filename to get the last 10 lines of a text file
  • cat filename to show the full content of a file; cat filename | grep keyword to only print the lines containing the specific keyword

8. Edit Files (Insert/Save/Quit/…)

Use vi filename to view the file in text editor.

  • To insert: type i
  • To exit: press Esc to exit edit mode, followed by :wq to save and exit, or :q! to exit without saving.

For example, to edit the previously created text file, save and exit:

9. Copy/Move Files

Use mv filename directory to move the specified file to the specified directory:

10. Zip/Unzip Files

  • To zip: gzip filename
  • To unzip: gunzip filename

Thanks for reading, hope this helps!😃 For more of my articles on Python and Cryptocurrency, kindly refer to:

Linux
Ubuntu
Recommended from ReadMedium