From Windows to Linux Command Line

From Windows to Linux Command Line

Introduction to Shell Basics and Navigation

·

5 min read

As a Windows operating user, various installations needed to be done before using Shell which is the command-line interpreter for Linux. Different operating systems set different working computer environments. To run programs that run on Linux to a windows machine and versa, a virtual environment needs to be set up as one of the ways.

In a virtual environment, programs meant for the different operating systems will run as they would in a host machine. There are virtual machine providers and tools to establish this setting with available information from the internet on how to do it. Once set, this is a guideline to navigate on the Linux command line also known as Shell.

tux-293844_640_1.png

What is Shell?

Shell is a command-line interpreter that takes in user input from the keyboard to be executed by the OS. As the outermost layer of the operating system, it acts as a link of communication between users and the kernel by processing user input that instructs a task to be done by the OS. Examples of Shell include Bash, PowerShell, etc

What is the difference between a Terminal and Shell?

The terminal is a program that accepts input from the keyboard and displays them on screen. An example is the command line prompt which is mostly available in Windows OS. On the other hand, a shell is a program that interprets the commands entered in the terminal, to be executed by the OS.

So the terminal provides an environment to take users' commands while the shell simply interprets the commands to provide access to OS services.

What is Shell prompt?

A Prompt indicates where to type in a command. Shell prompt appearance is $ (dollar sign). In Windows, the command line prompt symbol is ">" (greater than sign).

spiderman-homecoming.gif

The file system in Linux is structured hierarchically. The root / is the topmost level, where all other directories root from. There are directories that are present upon Linux installation. Example include

-/ - a root repository at the top level of the file structure

- /bin - where executables files is located

- /home -users directory, containing personal files , pictures, etc

- /tmp - holds temporary files.

Examples of commands to navigate the directory

pwd - prints the name of the current directory

pwd
/

This shows that the current working directory is at root / (root)

cd - change directory

cd home

Changing from root directory(assuming its the current working directory) to home directory

ls- display contents that are in a directory.

mary:/home#ls

What are the . and the .. directories?

  • . (single dot) stands for current directory

  • .. (double dot) stands for parent directory

Assuming one is inside a directory of another directory and so on... how does one get back to the parent directory? As stated, since the cd command is used to change directories, adding two dots on the command directs one to the parent directory.

cd ..

What is the difference between root and home directory?

The root is the main repo for all the directories in Linux. A root user has all the privileges to modify anything in the entire system. The home directory is contained in the root directory, and a home user has only access to the home directory.

What are the characteristics of a hidden file and how to list them

Hidden files are files that are not visible when performing the usual ls command. The files start with a dot (.) and in order to access them, the "-a" flag is put after ls command.

ls -a

To create a hidden file

touch .hello

Now a hidden file called hello is created. When one gives the ls command, it will not be listed, until the "-a" flag is put after the command and it will be visible.

Looking Around

via-lil-nax.gif

As already seen the ls command list a directory's content.

  • ls -a -list files and directories including the hidden ones.

  • ls -l - reveals more detail. By adding l, the output has been changed to a long format

More commands.

  • file - prints a brief description of the file contents such as information about the file type.
  • mkdir - creates a directory
  • touch - creates a file
  • rm - deletes a file
  • rmdir - deletes a directory
  • less - view contents of a file
  • vim - a free and open-source text editor from Linux to edit a file

How do we use options and arguments with commands?

Most Linux commands are presented as

commands = options arguments

whereby

  • options are prefixed with a dash -. Example -a, --delete

  • argument is the filename where the command will act upon.

A good illustration of what is a symbolic link is shortcuts on the desktop. When deleted, it doesn't mean the actual data that the shortcut points to have been deleted. The shortcut file can still be generated because it acts as a reference to the actual file or to a program.

So, a symbolic link is a link that points to a location of an original file. When the original file is deleted, and the symbolic file is still present, the link is said to be broken because the symbolic link is pointing to a non-existing file.

A hard link points to a physical location on a hard drive as opposed to another file. Deleting a hard link deletes all the contents of the file whereas deleting a symbolic does not affect the original file it is pointing at.

These are just but brief basic information and commands on Shell. What part did you find helpful? Thank you for reading.