10 Important UNIX Commands for Beginners..
Learn 10 important basic commands to help navigate the Unix command line.
If you're coming from Windows Operating System to a Linux OS then my money is on the fact that you will find the command line to be a bit difficult to navigate.
From directory mapping to reading files, writing files, deleting files; the command line has totally different commands which you must get comfortable with.
In this article, I'll show you 10 important commands to help you get started.
What you'll learn:
- List Directories
- Create Directories
- Navigate into Directories
- Map directory URL.
- Create files
- Delete files
- Rename files
- Read files.
- Map Directory Tree
- Copy file
Alright, let us dig in!!
1.List Files and Directories --------------------- ls
The ls command is a basic Linux command used to list files and directories within the file system. The package comes pre-installed in Linux systems and can be used in different ways.
ls /etc
To know more about the capabilities of the ls command, use the man command: man ls
2.Create Directory --------------------- mkdir
Pretty straightforward, the mkdir
command helps create a directory.
mkdir new_directory
3.Navigate into Directory --------------------- Cd
The Cd command helps you change directories or folders. Using the cd alone takes you to the top of the directory tree; I call it the user directory. Say you want to get into the etc directory:
cd /etc
Well done, you're in the /etc directory now. To go back directories, use cd..
cd..
4.Display Directory Path --------------------- pwd
Using the pwd
command displays the path of the current working directory.
5.Create files --------------------- touch
To create files in UNIX we use the touch
command
touch file_name
6.Delete files --------------------- rm
The rm
command deletes files from the command line
rm file_name
7.Rename files --------------------- Mv
Renaming files in UNIX is a bit funny because the command is the same as the command used to move files. The Mv
command stands for the move and is used to move files from one directory to the other. However, it can also be used to rename files.
Mv file_name new_name
8.Read files --------------------- Cat
or Less
To read the content of files we use the cat
or Less
command.
Note that you can only read the content of the files with this command but can't edit.
cat file_name
Less file_name
9. Map Directory Tree --------------------- Tree
Linux has a command that allows us to list directories and files in a structure/tree format. The command package does not come pre-installed so has to be installed.
First, install the Tree
command using apt-get
(for Ubuntu users)
apt-get install tree
Tree /directory_name
10.Copy file --------------------- Cp
Copying files from one directory to another is super easy with the Cp
command.
Cp file_name directory_name/
Yes!! You made it to the end of this article, i hope this helps you in your dev journey.