Table of contents
No headings in the article.
CONTENTS
1. Work with files and directories commands
2. User, system, and hardware commands
3. Disk usage commands
4. How to become a root user
5. Packages installation by using yum commands
SO WHAT IS LINUX COMMAND
* Linux command is a utility of the Linux operating system that runs on the command line.
* Basic and advanced tasks can be done by executing commands.
* The commands are executed on the Linux terminal to interact with the system.
TO WORK WITH FILES AND DIRECTORIES
* pwd---> This command displays the current working directory
* ls---> This will list the content of a directory
* ls -la---> This command will list all the content of a directory
including the hidden files & directory
* mkdir---> This command will create a new directory
(for example mkdir avengers)
* mkdir -p---> This command will create a nested directory
(for example mkdir -p avengers/ironman)
* rmdir---> This command will remove delete an existing directory
provided its empty
* cd---> This command is used to change the directory
* touch [name of the file]---> This command will create a new file
(for example touch hulk.txt)
* rm [name of the file]---> This command will delete a file
(for example rm hulk.txt)
* rm -f [name of the file]---> This command forcefully deletes a file
(for example rm -f hulk.txt)
* rm -r [name of the directory]---> This command will delete a directory
along with its content (for example rm -r avengers)
* rm -rf [name of the directory]---> This command forcefully and recursively
deletes a directory along with its content
* cp ---> This command copies files from one location to another
This command can also copy directories
* cp -r [name of directories]---> This command copies the content of directories
(for example cp -r dir1 dir2)
note: if directory dir2 doesn't exist then it is created if it
exists its content is overwritten
* mv ---> This command is used to rename files and directories
(for example, Let's say you want to rename index.html to web_page.html)
* cat [file name]---> It will display the content of the file in terminal
* chmod ---> Is a common command that modifies a file or directory
read, write, and execute permissions
(for example, the owner is currently the only one with full permission to
change file1.txt to allow others to read, write, and execute the file and change
it to the -rwxrwxrwx permission type whose numeric value is 777
chmod 777 file1.txt, chmod 755 file1.txt for set rwx to the owner and r_x to the
group and everyone chmod 766 file1.txt sets rwx for owner rw for group and
every one)
USER SYSTEM AND HARDWARE COMMANDS
* whoami ---> This is generally used to identify the currently logged-in user
* who ---> Who command is used to get information such as the time of the last system boot,
current run level of the system, list of logged-in users, and more
* id ---> This command is used to display the information of a real and effective current user
* finger ---> It shows the current user name, terminal name, write status, ideal time, and login
time
* finger [name] ---> This is used to print specific user name
for example (finger username)
* lastlog ---> It is used to find the details of a recent login of all user
* uname -a ---> It shows all the system information like [ kernel, name, network node,
hostname, kernel release date, kernel version, machine hardware name,
hardware platform, operating system]
* uname -s ---> It shows the kernel name
* uname -n ---> it shows the hostname of the network node
* uname -r ---> It shows the kernel release
* uname -v ---> It shows the version of the current kernel
* uname -m ---> It shows the machine hardware name
* uname -p ---> It shows the type of the processer
* uname -o ---> It shows the name of the operating system
* uname -i ---> It shows the platform of the hardware
* adduser [name of the user] ---> this command will add a new user
* userdel -f ---> this command forces the removal of the specified user account it
doesn't matter that the user is still logged in
DISK USAGE COMMANDS
* df ---> This command shows the amount of disk space used and available on the file
* du ---> It shows the amount of disk space used by the specified files and for each directory
* df -h ---> It shows the information in human-readable format
* df -m ---> It shows output size in megabytes
* df -k ---> shows the size in kilobyte blocks
HOW TO BECOME A ROOT USER
1. Root user is like an admin user which has complete control of the system
2. If you want to run any privileged command in your Linux-based servers then you need to have
root access
3. There are 5 best ways through which you can become the root use
[ sudo -i, sudo -s, sudo -su, su -root, su - ]
PACKAGE INSTALLATION BY USING yum COMMAND
yum ( yellow dog updater ) provides more service and functionality than is available with the
rpm command and other rpm-based tools
* yum install [ package name ]
* yum reinstall [ package name ] ---> to reinstall the current version of the package
* yum remove [ package name ] ---> to remove the package and all its dependencies from the
system
* yum swap [ package name ] ---> to remove one package and install another package using
single command using the swap option
* yum update ---> to update all the packages available on the system
* yum update [ package name ] ---> to update a specific package like httpd
NOTE:- use -y option with any yum command to assume the answer to any question as yes and
provides a non-interactive use of the yum command
( for example yum update -y )
THANKS FOR READING
I am a beginner and I keep learning. all the above commands which I found it was useful in my early stage hope some beginners like me find this useful. if any corrections need means make comments and let us learn together.