Sunday , December 6 2020

The Ultimate Linux Guide Full Tutorial

Welcome to our ultimate guide to the Linux Command Line. This tutorial will show you some of the key Linux command line technologies and introduce you to the Bash scripting language.

Now the first question arises in your mind is that What is Bash?

Bash (short for Bourne Again Shell) is a Unix shell, and a command language interpreter. A shell is simply a macro processor that executes commands.

Many things that can be done Linux operating system can be done via command line. Some examples are…

  • Editing files
  • Adjusting the volume of the operating system
  • Fetching web pages from the internet
  • Automating work you do every day
  • Downloading the Github repositories

Linux Command Line Terminal Shortcuts:

First, we’ll cover some tips that will make the command line easier to use:

  • Use tab for auto completion. After you start typing something in the Linux terminal, hit tab and it will suggest possible options that start with the string you have typed so far.
  • Use ctrl+r search_term to search commands you have previously used.
  • Quickly move to the beginning or end of a line with ctrl+a and ctrl+e
  • Reuse the previous command in the present command with !!
  • You can run multiple commands in a single line by separating commands with a ;

Linux Command Line:

Linux has a ton of commands, but most people only use a fraction of them. Here are some of the most used Linux commands to use in the terminal.

ls

List directory contents.
Example: ls /applications will display all the files and folders stored in the applications folder.

cd

Change to a directory.
Example: Change from the current directory to /usr/local with cd /usr/local

mv
Rename or move file(s) or directories.
Example: the command mv app.txt /home/alifya/Documents would move “app.txt” to the “Documents” directory.

mkdir

Create a new directory.
Example: mkdir iotfiles will make a directory named “iotfiles”.

rmdir

Delete empty directories.

touch

Create an empty file with the specified name.

rm

Remove file(s) and/or directories.
Example: rm app.txt will delete the file.

locate

Locate a specific file.
Example: locate -i rust*module command will search for any file that contains the word “rust” and “module”. The -i makes the search case-insensitive.

clear

Clear a command line screen/window for a fresh start.

cp

Copy files and directories.
Example: the command cp app.txt /home/alifya/Documents would create a copy of “app.txt” to the “Documents” directory.

alias

Create an alias for Linux commands.
Example: alias search=grep will allow you to use search instead of grep

cat

Display the contents of a file on the screen.
Example: cat app.txt will show the text of “app.txt” on the screen.

chown

Change who owns a file.
Example: chown alifya app.txt will make “alifya” the owner of “app.txt”.

chmod

Change a file’s permissions.
Example: chmod 777 app.txt will make “app.txt” readable, writable, and executable by everyone. The digits in “777” specify the permissions for user, group, and others, in that order.

How to Write permissions?

Here are some of the examples that will help you understand the structure of writing the permissions.

sudo

Perform tasks that require administrative or root permissions.
Example: Use sudo passwd alifdgr8y to change the password of user “alifya”.

find

Search for files matching a provided pattern. This command is for searching file(s) and folder(s) using filters such as name, size, access time, and modification time.
Example: find /home/ -name todo.txt  will search for a file named “todo.txt” within the home directory and its subdirectories.

grep

Search files or output for a particular string or expression. This command searches for lines containing a specified pattern and, by default, writes them to the standard output.
Example: grep run todo.txt will search for the word “run” in the “todo.txt” file. Lines that contain “run” will be displayed.

date

Display or set the system date and time.

df

Display report on the system’s disk space usage.

du

Show how much space each file takes up. This will show the size in disk block numbers. If you want to see it in bytes, kilobytes, and megabytes, add the -h argument like this: du -h.

file

Determine the type of a file.
Example: file todo.txt would likely show the type of “ASCII text”.

history

Shows the command history.

kill

Stop a process.
Example: Stop a process with a PID of 485 using the command kill 485 Use the ps command (below) to determine the PID of a process.

less

View the contents of a file one page at a time.
Example: less todo.txtwill display the contents of “todo.txt”.

ps
Display a list of the currently running processes. This can be used to determine PIDs needed to kill processes.

pwd

Display the pathname for the current directory. “print working directory”

ssh

Remotely log in to another Linux machine, over the network.
Example: ssh alif@104.25.105.32 will login to 104.25.105.32 using the username “alif”.

tail – Display the last 10 lines of a file. See fewer or more lines by using the -n (number) option.
Example: tail -n 5 todo.txt will display the last 5 lines of “todo.txt”.

tar

Store and extract files from a tarfile (.tar) or tarball (.tar.gz or .tgz).

top

Displays the resources being used on your system, similar to the task manager in Windows.

About Alifya

Check Also

Natural Language Processing In Artificial Intelligence

What is Natural Language Processing? In the NLP, we use the English language to interact …

Leave a Reply

Your email address will not be published.