Linux Command Line

Linux Command Line

Different Linux commands important to navigating and getting basic tasks done

What is the shell?

The shell is basically a program that takes your commands from the keyboard and sends them to the operating system to perform.

Commands Lines

echo

The echo command just prints out the text arguments to the display.

echo Hello World

pwd (Print Working Directory)

Every file is organized in a hierarchical directory tree. The location of these files and directories are referred to as paths.

pwd

The above command shows you which directory you are in, note the path stems from the root directory.

cd (Change Directory)

cd .

(current directory). This is the directory you are currently in.

cd ..
cd ~
cd -

cd.. (parent directory) Takes you to the directory above your current.

cd~ (home directory). This directory defaults to your “home directory”

cd - (previous directory). This will take you to the previous directory you were just at.

ls (List Directories)

The ls command lists directories and files in the current directory. It shows comprehensive information about the files and folders you are viewing.

$ ls

$ ls /home/matt

Not all files in a directory will be viewable, it should be noted. Filenames that begin with a dot are concealed; but even so, you can read them by using the ls command with the -a flag (a for all).

Text Commands (Text-Fu)

The grep Command

grep is one the most frequent text-processing command in Linux. It enables you to look through files by looking for characters that fit a specific pattern. Rather than going through every line of text, the grep function allows you find a file in a specific directory or a string embedded in a file without much ado. grep is a versatile tool, you can also use it with regular expressions and other commands.

$ grep
$ ls /somedir | grep '.txt$'

cut

This magical function helps us extract a chunk of file from another directory.

$ cut

paste

This command allows you add to an existing directory or file.

$ paste -s with the new file or text

tr (Translate)

The translatef command is another useful function that allows you translate or change a set if character into your desired characters. For example, you can change a set of characters of upper case to lower case.

$ tr a-z A-Z

MOLLY

molly

The 'a-z A-Z' range indicates that alphabets that you need translated.

exit

The above command are just a few important commands. There are many more you'll still get to read about here. In the meantime, let's learn the exit command. Because, after all, you need to leave the shell some times.

$ exit

If you don't want to use the exit command, an alternative is the logout command.

$ logout

PS: the exit or logout command is not necessary if you're working on a normal terminal GUI. Just close that.

Thank you for dropping by 😃... You can collaborate with me by sending in a message via my social media handles.

References

kinsta.com/blog/linux-commands

linuxjourney.com