• About
  • Advertise
  • Careers
  • Contact
Thursday, February 19, 2026
  • Login
No Result
View All Result
NEWSLETTER
Blacklight News
  • Home
    • Home – Layout 1
    • Home – Layout 2
    • Home – Layout 3
    • Home – Layout 4
    • Home – Layout 5
  • World
  • Home
    • Home – Layout 1
    • Home – Layout 2
    • Home – Layout 3
    • Home – Layout 4
    • Home – Layout 5
  • World
No Result
View All Result
Blacklight News
No Result
View All Result
ADVERTISEMENT

Basics of Using The Command Line 

by Ezekiel
October 21, 2022
in Uncategorized
1
Basics of Using The Command Line 
0
SHARES
62
VIEWS
Share on FacebookShare on Twitter

For anyone who works with computers, it is important to have at least a basic understanding of the command line and some of the most basic Linux commands. The command line is a text-based interface that allows users to interact with a computer by typing commands. This is in contrast to the graphical user interface (GUI), which uses images and icons to represent commands and files. The command line can seem intimidating at first, but it is actually very powerful and efficient once you get used to it. In addition, learning some basic Linux commands can be incredibly useful, even for users who are mostly accustomed to using a GUI.

One of the biggest advantages of the command line is that it is much more transparent than a GUI. When you type a command, you can see exactly what it does and how it affects the system. This can be very helpful when troubleshooting problems or trying to understand how a particular program works. In addition, the command line allows you to automate repetitive tasks by writing scripts. Scripting can save you a lot of time and effort in the long run, so it is definitely worth learning how to do it.

Of course, learning the command line and basic Linux commands does take some time and effort. However, it is undoubtedly time well spent. Once you have mastered these skills, you will be able to work with computers much more efficiently and effectively. In this article, we’ll introduce some of the most commonly used Linux and Unix commands.

If you’re using Linux, a Macbook or a virtual machine running Linux, feel free to fire up a terminal and practice along with the following instructions. Remember practice makes perfect!

How To Find Help

Before we begin one of the most important things to remember is that you can always find help by typing “man” at the terminal. “Man” stands for manual, so when in doubt, type “man” followed by the name of the command you’re trying to use. For example, let’s say you want to learn more about the ls command, which is used to list the files in a directory. (Don’t worry, the ls Command will be covered later on) To do so, you would type

 man ls 

and hit Enter. This would display the manual page for the ls command, which would list all of the available options for using ls. Keep in mind that you can usually find a brief description of most commands by typing just the command name followed by -h or –help. So if you’re ever stuck, don’t hesitate to use the man command

Basic Directory Navigation

The cd Command & The pwd Command

The cd Command

Basic Unix directory filesystem navigation is accomplished using the “cd” command. The “cd” command stands for “change directory”. When executed, this command will jump you to the specified directory. For example, if I wanted to jump to my home directory, I would simply type

cd ~

and hit enter. The tilde symbol (~) is a shortcut for your home directory. If I wanted to jump to the root directory, I would type

 cd /

and hit enter. The forward slash (/) is a shortcut for the root directory. You can also jump to a specific sub-directory by typing “cd /path/to/subdirectory”. For example, if I wanted to jump to the /etc/ subdirectory, I would type

 cd /etc/

and hit enter. As you can see, basic Unix directory filesystem navigation is quite simple once you know the basics of the “cd” command.

The pwd command

The “pwd” command is also very useful for navigation. The “pwd” command stands for “print working directory”. When executed, this command will print the full path of the current working directory to the terminal. This can be very helpful when you are not sure where you are in the filesystem. For example, if I am currently in the /etc/ subdirectory and I want to know the full path, I would simply type

pwd

and hit enter. The output would be “/etc/”.

Listing Directory Contents

The ls command

Once you know how to navigate the Unix filesystem with the “cd” command, you will need to learn how to list the contents of a directory. This is accomplished using the “ls” command. The “ls” command stands for “list”. When executed, this command will list all of the files and sub-directories in the current directory. For example, if I am in my home directory and I type

ls

I will see a list of all of the files and sub-directories in my home directory. If I want to see more information about each file and sub-directory, I can type

ls -l

The “-l” option stands for “long”. This will give me a long list of information about each file, including the file size, ownership, permissions, and modification date.

Creating and Removing Directories

The mkdir command & The rmdir command

At some point, you will probably need to create a new directory. This is accomplished using the “mkdir” command. The “mkdir” command stands for “make directory”. When executed, this command will create a new directory with the specified name. For example, if I want to create a new directory called “test”, I would simply type

mkdir test

and hit enter.

Take note when using the mkdir command that you cannot have any spaces in the directory name. If you try to put a space in the directory name, you will get an error that looks something like this

mkdir: cannot create directory `First Directory': No such file or directory

It’s not mandatory but only recommended to use hyphens or underscores in place of spaces.

If you want to use spaces in directory names, you have to put the name of the directory in quotation marks. For example, if I wanted to create a directory called “First Directory”, I would type

mkdir "First Directory"

or you can escape a whitespace by using a backslash. For example, to create a directory called First Directory2, I would type

mkdir First\ Directory2

and hit enter.

You can also delete an empty directory using the “rmdir” command. The “rmdir” command stands for “remove directory”. When executed, this command will delete the specified empty directory. For example, if I want to delete the “test” directory that I created in the previous example, I would type

rmdir test 

and hit enter.

Take note that to remove a folder using the rmdir command , the folder must be empty. If you need to delete a directory that is not empty, you will need to use the “rm -r” command instead (which will be discussed in the next section).

Creating and Deleting Files

The touch command & The rm command

You can also create a new file using the “touch” command. The touch command is intended to create new empty files. However, you can also use it to update the timestamps on existing files. For example, if I want to create a new file called “test.txt”, I would type

touch test.txt

and hit enter. This will create a new empty file called “test.txt” in the current directory.

If the “test.txt” file already exists, executing the touch command will simply update the timestamp on the file without changing its contents.

You can delete a file using the “rm” command. The “rm” command stands for “remove”. When executed, this command will delete the specified file. For example, if I want to delete the “test.txt” file that I created in the previous example, I would type

rm test.txt

and hit enter. Take note that the remove command is very powerful and should be used with caution, as it cannot be undone. There is no way to recover a file once it has been deleted using the rm command.

If you want to delete a directory that is not empty, you need to use the “rm -r” command instead. The “-r” option stands for “recursive”. When used with the rm command, this option will delete the specified directory and all of its contents. For example, if I want to delete the “test” directory that I created in the previous section, I would type

rm -r test

and hit enter. This will delete the “test” directory and all of its contents. Use this option with caution, as it cannot be undone either. Please do not confuse the remove command with the rmdir command, as they are two very different things.

Copying and Moving Files

The cp command & The mv command

You can also copy a file from one location to another using the “cp” command. The “cp” command stands for “copy”. When executed, this command will make a copy of the specified file in the specified location. For example, if I want to copy the “test.txt” file that I created earlier to my home directory, I would type

cp test.txt ~/

and hit enter. This would result in a new file called “test.txt” being created in my home directory with the same contents as the original “test.txt” file.

You can also use the cp command to copy entire directories. For example, if I want to copy the “test” directory that I created earlier to my home directory, I would type

cp -r test ~/

and hit enter. This would result in a new directory called “test” being created in my home directory with the same contents as the original “test” directory.

The “-r” option that is used in this example stands for “recursive”. When used with the cp command, this option will cause the command to copy all files and subdirectories within the specified directory (rather than just copying the directory itself).

You can move a file from one location to another using the “mv” command. The “mv” command stands for “move”. When executed, this command will move the specified file to the specified location. For example, if I want to move the “test.txt” file that I created earlier to my home directory, I would type

mv test.txt ~/

and hit enter. This would result in the original “test.txt” file being deleted from its current location and a new file called “test.txt” being created in my home directory.

You can also use the mv command to move entire directories. For example, if I want to move the “test” directory that I created earlier to my home directory, I would type

mv test ~/

and hit enter. This would result in the original “test” directory being deleted from its current location and a new directory called “test” being created in my home directory.

The difference between the cp command and the mv command is that the cp command makes a copy of the specified file (or directory), while the mv command actually moves the specified file (or directory).

Viewing File Contents

The cat command & The less command

You can view the contents of a file using the “cat” command. The “cat” command stands for “concatenate”. When executed, this command will display the contents of the specified file on the screen. For example, if I want to view the contents of the “test.txt” file that I created earlier, I would type

cat test.txt

and hit enter.

The “cat” command is useful for small files, but it can be difficult to use for large files because the entire contents of the file are displayed on the screen all at once. In these cases, it is often more convenient to use the “less” command. The “less” command stands for “view less”. When executed, this command will allow you to view the contents of a file one page at a time. You can scroll through the file using the up and down arrow keys on your keyboard. less also offers vim bindings for you to search through the text, vim bindings are handy way to be able to quickly move your cursor and search for specific strings of characters. To exit out of less simply type q.

To view the contents of a file using the “less” command, you would type

less test.txt

and hit enter.

You can also edit a file using the cat command by specifying the file you wish to edit followed by the greater than signs. This will open up a blank document which you can start writing in.

cat > test.txt

now type the following 10 lines of text.

This is the first line
This is the second line
This is the third line
This is the fourth line
This is the fifth line
This is the sixth line
This is the seventh line
This is the eighth line
This is the ninth line
This is the tenth line

To save and exit out of this file simply type Ctrl + d

You can view what you have just written in your file by typing

cat test.txt.

Output Control

The head and tail commands

“Head” allows you to view the beginning of a file, while “tail” lets you see the end. By default, “head” displays the first 10 lines and “tail” shows the last 10. But this can be changed by using the “-n option.” For example, say I want to check out only five lines from my earlier created file “test.txt.” To do that with head, I would type

head -n 5 test.txt

And hit enter. If it’s tail I’m interested in seeing the last five lines from our sample text file then I would type bash

tail -n 5 test.txt

and hit enter. These commands are often used in combination with other Linux commands to achieve a desired goal.

Searching File Contents

The grep command & The find command

You can also use the “grep” command to search for specific text within a file. The “grep” command stands for “global regular expression print”. When executed, this command will search the specified file for the specified text and display any lines that contain that text. For example, if I want to search the “test.txt” file for the word “seventh”, I would type

grep seventh test.txt

and hit enter.

This would result in the following output being displayed:

This is the seventh line

If you want to search for multiple You can also use the “find” command to search for files that contain specific text. The “find” command will search the specified directory for files that contain the specified text and display the names of those files. For example, if I want to search the current directory for files that contain the word “test”, I would type “

find . -name '*test*'"

and hit enter.

This would result in the following output being displayed:

./test.txt

Be sure to read the man page for both the grep and find commands as there are a variety of options that can be specified when using them.

I know that was a lot to go over but congratulate yourself you’ve made to the end. These are just some of the basic commands that you will need to know in order to get started using the Unix command line. In future posts, I’ll be covering some of the more advanced commands as well as how you can use the command line to automate various tasks.

So If you’re feeling daring, why not try out a few of these commands on your computer? Just be sure to type man and the command for more information on how to use each one. With a little practice using these commands on your computer , you too can become a Unix master. Thanks for following along! I hope you enjoyed this introduction to Unix commands – stay tuned for more tutorials coming soon!

Tags: Tech
Ezekiel

Ezekiel

Next Post
Black Balled At the Bank: 71 Year Old Woman Accuses Bank of Discrimination

Black Balled At the Bank: 71 Year Old Woman Accuses Bank of Discrimination

Comments 1

  1. Stephen says:
    3 years ago

    Thank you! This looks like a great start for my Linus journey!

    Reply

Leave a Reply Cancel reply

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

Recommended

Biden Announces Proposal to End the Student Loan Debt

North Carolina Teen Earns Title Of Fastest Runner In America 

3 years ago
Basics of Using The Command Line 

Basics of Using The Command Line 

3 years ago

Popular News

  • Are Automated Journalism Tools Destroying The News Industry?

    Are Automated Journalism Tools Destroying The News Industry?

    0 shares
    Share 0 Tweet 0
  • Biden Announces Proposal to End the Student Loan Debt

    0 shares
    Share 0 Tweet 0
  • North Carolina Teen Earns Title Of Fastest Runner In America 

    0 shares
    Share 0 Tweet 0
  • Florida Man Shoots Student Over $1

    0 shares
    Share 0 Tweet 0
  • The Science Behind Why Janet Jackson’s Rhythm Nation Can Cause Laptops To Crash

    0 shares
    Share 0 Tweet 0

Connect with us

Facebook Twitter Youtube RSS

Category

  • National

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In
No Result
View All Result
  • Home
  • World
  • National
  • Gaming
  • Movie

If you're looking for a way to stay up-to-date on the latest news, events, and happenings, then subscribing to our newsletter is the perfect solution! Not only will you receive regular updates, but you'll also get exclusive access to articles, tips, and advice that you won't find anywhere else. So what are you waiting for? Subscribe today!