Linux Tutorial For Beginners- Part I
- Last Updated On: March 6, 2014
- By: Scriptcrunch Editorial
Linux is an awesome OS to work with. It is very malleable and it is really really fun to work with linux OS. Am not going to elaborate on this. Just read the article published by redhat and You will understand why you should learn Linux.
Read: why should you learn linux
When you start learning about linux , Redhat, Ubuntu, centos , Fedora, suse and mint are names that would be going through your brain. But believe me, there are nearly six hundred different distros of linux. I suggest you to start with Centos ( a derivative of Redhat enterprise linux) and Ubuntu ( a debian based distro). Choosing a distro is of your choice. For more info on choosing a distro , read this
In this tutorial I will be explaining the important things to do when you start learning the Linux command line. I started learning linu from udemy course. If you are new to linux and you want a good grip on linux, you can subscribe for the online course. It is a really good course for linux foundation.
Course link: Linux tutorials by linux academy
Shell: To run command in Linux we use a command line interpreter called shell. You can virtually do any Linux based operations using the shell.
You can open a shell terminal using the GUI options in your distro or you can user Ctrl + Alt + T shortcut keys to open the terminal.
Also read: Linux shell scripting beginner tutorial
cat command is used to view the contents of a file. The information about the CPU and OS are present inside files under the /etc folder.
1. Command to view the cpu information
cat /proc/cpuinfo
2. Commad to find the OS details
cat /etc/*release*
1. Open the terminal and issue the following command to execute commands as root.
sudo su
2. To Create an user , lets say scriptuser , execute the following command in the terminal
useradd -s /bin/bash -m -d /home/scriptuser -g root scriptuser
the above command creates a user “scriptuser”, create the home directory for the user.
3. Add password for the user.
Passwd scriptuser
4. Only the root user will have all the privileges to execute and modify all the files in the server. Inorder for the user to have certain privileges to executes commands and install softwares, it should have some root privileges. To provide the user root privileges , you should add the user to ther sudoers list. Sudoers file will be present inside the /etc folder. location: /etc/sudoers. Use any one of the foloowing commands to open the sudoers file.
vi /etc/sudoers (or)
visudo
vi is the editor for linux. There are other ediotors like nano.
5. Add the following line to the sudoers file.
scriptuser ALL=(ALL:ALL) ALL
scriptuser is the username and ALL=(ALL:ALL) ALL will give the user certain root privileges. After adding this line , press Esc key , w and q to save the edited file. Now you will be able to execute commands using root privileges by using sudo before the command.
1. Create a directory using the following command
mkdir directory_name
2. Remove a directory
rmdir directory_name
3. You can browse through the directories using cd (current directory) command
cd /dir1/dir2
4. You can find the current working directory using the following command.
pwd
vi is the commonly used and a very powerful text editor.
1. Open a file
vi filename
2. Save a file by pressing the following keys consequently.
esc + w +q
3. Exit the file without saving
esc + q
4. Search for a particular word in a file
/keyword + enter
5. Delete a particular line
<pre>use dd by placing the cursor in the line which you want to delete the file.</pre>
6. Undo the action by pressing u
7. Copy and paste and particular line
yy to copy and
p for paste
To create a file you can either use the editor or touch command.
1. If you create a file using touch command, the file size will be zero.
touch filename
2. Creating a file using vi.
vi file name
3. Deleting a file
rm filename
4. Force deleting
rm –f filename
5. To delete all the files in a folder , cd in to the directory and issue the following command.
rm –rf *
r stands for recursive and f stands for force, * denotes all.
6. To delete a folder with files.
rm –rf foldername
7. Create a hidden file by appending a . operator before the file name.
mkdir .dirname
touch .filename
1. You can list all the files and folders using the ls command.
ls
2. Use the following command to list all the hidden folders
ls –a
3. List all the files with particular extension.
ls *.png
ls *.sh
4. List all the files with their starting with a
ls a*
5. List all the files starting with letter a to d from a particular folder
ls /folder-name/[a-d]*
kindly share this article and leave a comment for queries.
Scriptcrunch Editorial
Other Interesting Blogs
[80% OFF] Linux Foundation Coupon for December 2024
Looking for CKA Coupon and other Linux Foundation certifications coupons? We got you covered. With the latest Linux Foundation Coupon, you can
Best Black Friday Deals For Techies in 2024
In this blog, we have listed down all the best Black Friday deals and Cyber Monday deals for techies. This is the
[40% OFF] Linux Foundation LFCA, LFCS & LFCT Exam Voucher Codes
Linux Foundation has announced up to a $284 discount on its Linux certification programs Linux Foundation Certified IT Associate (LFCA) and Linux