0% found this document useful (0 votes)
159 views

Linux Fundamentals

Linux is an open-source operating system that is free, secure, and stable. It provides basic commands like ls to list files, pwd to print the working directory, and mkdir to create directories. It also allows you to create users and groups, compress files using tar and gzip, and set file and folder permissions using chmod.

Uploaded by

Bhaskar kovvuru
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
159 views

Linux Fundamentals

Linux is an open-source operating system that is free, secure, and stable. It provides basic commands like ls to list files, pwd to print the working directory, and mkdir to create directories. It also allows you to create users and groups, compress files using tar and gzip, and set file and folder permissions using chmod.

Uploaded by

Bhaskar kovvuru
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

LINUX FUNDAMENTALS

What is Linux and why it is so popular?


 Linux is an open-source and community-developed operating system for computers, servers,
mainframes, mobile devices, and embedded devices.
 Linux is different from the rest of the operating systems in many important aspects which
are :-
 Free
 Open Source
 Secure
 Stability and Performance

Linux basic commands


 ls :- list files
 ll :– long list of files
 ls –a :- list of hidden files
 ls –la :- list of all files including hidden files
 pwd :- present / print working directory
 cd .. :- this will bring you back to one previous folder
 ls ‘complete path’ :- this will show all the files in the mentioned folder
 mkdir directoryname :- to create a directory
 mkdir –p dir1/dir2/dir3 :- to create a directory one inside one
 touch ‘filename’ :- to create a file
 sudo su :- super user do switch user (to gain root access)
 rm –rf file1 :- to remove/delete file1
 rm –rf * :- to delete all the files present in the pwd
 ctrl + c :- to come out / to exit from current command
 history :- to get the history of commands used
 hostname :- to display hostname of your computer / instance / server
 ifconfig :- to get the ip address of your computer
 cat /etc/os-release :- using cat command we are opening os-release file present in /etc dir to
view the operating system details.
 cp file1 dir1 :- to copy file1 to directory dir1
 mv file1 dir1 :- to move completely file1 to directory dir1
 mv file1 file2 :- to rename file1 to file2
 yum update –y :- to update system with latest updates
 yum install packagename :- to install a particular package
 -y :- - (hyphen) y is a flag to skip interruptions asking to click/give “yes”
 yum install httpd –y :- to install httpd package
 yum remove httpd :- to remove httpd package
 yum list installed :- to list all the installed packages
 service httpd start :- to start the httpd service
 service httpd stop :- to stop the httpd service
 service httpd restart :- to restart the httpd service
 chkconfig httpd on :- to initiate automate restart once system restarts
 chkconfig httpd off :- to disable automate restart once system restarts
 wget package.url :- to download the external package from internet
 Ex:- http://ftp.gnu.org/gnu/wget/wget-1.5.3.tar.gz
 grep ‘element_to_search’ filename :- to search a particular element in file
 sort :- to sort the results either alphabetically or numerically
 head :- to view the top 10 starting lines of the file
 tail :- to view the bottom 10 lines of the file
 echo “hello” > file1 :- this will redirect the input hello inside file1
 which :- to verify any packages are installed or not
 tree :- to display the file and folders in a tree structure
Creation of User ID’s and Groups
 useradd ‘username’ :- to add the user
 passwd ‘username’ :- to set password to the user
 userdel ‘username’ :- to delete the user
 cat /etc/passwd :- to check all the users present
 groupadd ‘groupname’ :- to create a user group
 groupdel ‘groupname’ :- to delete a user group
 cat /etc/group :- to check all the groups present
 gpasswd –a username groupname :- this will move the user to the group
 gpasswd –M user1,user2,user3 group :- to move multiple users to the group
 ./ - this is the top level directory
 /root - this is the home dir. for root user
 /home - it is the home dir. for other users
 /boot - it contains bootable files of linux
 /etc - it contains the configuration files of linux
 /usr - by default softwares are installed in this dir.
 /bin - it contains commands used by all users.
TAR files – Creation and Extraction
 In windows operating system we have .zip files which are collection of files combined
together into one single file to minimize the file size and for purpose of sending to the other
users easily.
 Similar to zip files we have .tar which act similarly in Linux OS
 .tar – to pack multiple files so that we can send the files to others easily
 .gz (zip) – to compress the .tar files further so the file size is further reduced

TAR AND GZ COMMANDS (APPLICATION)


 To add tar to a normal file the command is
 tar –cvf file.tar file
 here –c = create (applying tar)
 -v = verbose (output will be shown during runtime)
 -f = forcefully
 file.tar = output of the file after applying tar
 file = the name of the file which we want to apply tar
 To zip a tar file, the command is
 gzip file.tar
 gzip = the command to apply zip
 file.tar = her the file.tar is the name of the file to which we are applying tar
 once zip is applied the o/p of the file will be file.tar.gz

TAR AND GZ COMMANDS (REMOVAL)


 To unzip a tar file, the command is
 gunzip file.tar.gz
 gunzip = the command to unzip the tar file
 file.tar.gz = here the file.tar.gz is the sample tar file
 To untar a tar file, the command is
 tar –xvf file.tar
 here –x = extract the file
 -v = verbose (output will be shown in real time)
 -f = forcefully
 After untar command we can check the output of the file and the files will be in original
format
 Bonus – to copy a file in Linux we can use SCP command as below
 scp file.txt [email protected]:/remote/directory

Files and Folder permissions

 Read r = 4
 Write w = 2
 Execute x = 1
 chmod 777 file1 :- to give full (read/write/execute) permissions
 chmod 666 file1 :- to give only read / write permissions
 chmod 700 file1 :- to give full permissions only to our userid

You might also like