Blog

Learning Linux Command Line Basics

Linux is an operating system that is a common alternative to Microsoft’s Windows operating system mainly because it’s open source which makes it free and also because of it’s security potential. Its open source nature makes it a flexible platform on which to launch solutions for various use cases. Unfortunately many of these use cases are foreign to average computer users; Programmers on the other hand are forced to get acquainted with these use cases because of Linux’s widespread use by service providers, third party tools and the general programming community at large.

Linux operating systems come in different “flavors”, Ubuntu, Fedora, CentOS to mention a few. Commands for each of these flavors may vary slightly but they are largely similar. In this article I’ll be focusing on Ubuntu commands because it is considered the most popular Linux flavor out there. I have met a number of developers who are weary of the command line and so I have divided the basic commands into general categories to make things a little easier to follow.

Navigation

Since there isn’t a GUI when it comes to terminals the only way to navigate is to type commands that change the directory that a user is in.

cd /directorypath – change your current directory to the “directorypath” indicated in the command.

cd /home/website/public_html/

pwd – display the path to the current directory.

find – search for files that match the word or pattern that follows the command

find error.log

ls – list the contents of a directory

ls
ls /var/www/html/
ls -l /var/www/html/

File Management

mkdir – create a new directory

mkdir newfolder
mkdir /home/website/newfolder

chmod – change file permissions

sudo chmod 755 robots.txt
sudo chmod -R 755 content

chown – change file ownership

sudo chown www-data:www-data config.php
sudo chown -R root:root content

cp – copy file from one directory to another

cp /home/website/config.php /var/www/html/

mv – move file from one directory to another

mv /home/website/config.php /var/www/html/

rm – delete a file

rm /var/www/html/config.php

User Management

ssh – remotely login to another remote terminal

ssh username@192.168.100.2

passwd [username] – change a username’s password

passwd username

su – switch user accounts

su - username

Misc

ping – sends a small data packet to the destination and requests a response. Mainly used for testing the connectivity of network terminals.

ping 192.168.100.5

We’ll end there for now. I hope these basic commands and examples will help you take the plunge into the command line and maybe even motivate you enough to become a Linux guru in the future. Feel free to let me know in the comments if I left out some commands that Linux beginners would benefit from. Until the next post, Cheers.

Leave a Reply

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