Basic Linux Commands
My very first commands that I learn when started diving into Linux, more specifically Ubuntu
There are many many commands out there, but within the scope of this article I want to share some basic commands that almost everyone can know.
1. pwd
pwd is used to print absolute path of current working directory and it takes no parameters. This is a command that even non-Linux users can also be familiar.
2. ls
ls is used to list the content of one or more directories. If we use the command without specifying any directories, then it will list content of the current working directory. However, ls can only list content of directories that the current user has permission to read,
3. cd
cd is used to change to specific directory in the system. It requires either absolute paths or relative paths and its default parameter is current user ‘s home directory.
Some basic uses of cd:
cd (without specifying directory): move to current user ‘s home directory
cd .. ( 2 dots): move to parent directory of current working directory
cd /etc/apt : move to directory /etc/apt
4. cat
cat command reads one or more files and write the copied content to standard output. It‘s often used to display short text files and can also be used to join multiple files together.
How to use:
cat filename
Get Nguyễn Tường’s stories in your inbox
Join Medium for free to get updates from this writer.
5. mkdir
mkdir is used to create one directory or multiple directories. We can also specify -p option to make parent directories if necessary in case we want to make nested directories.
6. touch
touch, on the other hand, is used to create one file or multiple files. File created by this command is always blank.
7. cp
cp command copies files or directories from original directories to different directories. It can be used in two ways:
cp item1 item2 : copies file or directory item1 to file or directory item2.
cp item… directory : copies multiple items (either files or directories) to a directory
8. rm
rm is used to delete file or directory but it can only delete directory if -r option is specified. Also when deleting directory, -f option is also specified along with -r option
9. mv
mv is used to move file or directory to from one place another place. It can also be used to rename file or directory like so:
mv old_file_name new_file_name
10. sudo
sudo stands for “SuperUser Do”, this command allows regular user to perform tasks such as installing new programs, update the system and many other administrative tasks. But great power always comes with great responsibility, this command must be used with extensive care so as not to damage the system.
References
The Linux Command Line 2nd edition, Chapter 3 + 4







