This is Day 12 of the #90DaysOfDevOps challenge. In today's blog and in the next blog I am making the brief cheatsheet of Linux commands, Git, and GitHub commands that I had covered in my earlier blogs but this blog is wholly documented for only all Linux Commands, or I can say I am putting all Linux blogs commands in one blog.
Linux Commands :
ls
- It will list all the files and directories that are present in your system.ls -ltr
- It will also list all the files and directories in a more formatted way.ls *.sh
- It will list all the shell script files.ls -a
- This will list all hidden files and directories.ls -i
- This will list all files and directories with an inode number (index number).pwd
- tells about the present working directory.history
- This will list all the commands you executed from logging into the system.mkdir <directory name>
- This command will create the directory.mkdir <. directory name>
- This command will create a hidden directory.cd
- To go back to the previous directory.cd ~
- To go back to the home directory.cd../..
- To go back to two steps.mkdir -p file1/file2/file3
- This command will create the nested directories.locate filename
- This will locate your file from the system. But before using locate command always update the databaseupdatedb
because locate uses a prebuilt database.passwd userid
- This will change the password of users and for root just typepasswd
under root.chmod
- To change file mode bits.chown
- To change file ownership.chgrp
- To change group ownership.man
- This command will help you to get the description of any command.cat filename
- This command will show the output of any file.setfacl
- This command provides more flexibility to change or set file permissions.getfacl
- By executing this command you will get all details of particular file permissions.echo
- Prints any text or line by executing this command.tee
- This command is used to store and view the output at the same time.cp
- Copy a file.rm
- This command will remove the file and executing-f
will remove the parent directory forcefully.mv
- Move a file or rename a file.more
- To view the contents in a single page by page at a time.head
- This command will show the contents from the top.tail
- This will show the contents of a file from the bottom.less
- Views the content in one line at a time in reverse order.cut
- This command allows you to cut the output.awk
- This command will list the columns.grep or egrep
- It searches for the specific keyword.sort
- Sorts out the output in alphabetical order.uniq
- Remove the duplicates.wc
- This command will count the words from a file.diff
- Compare the files line by line.cmp
- Compare files byte by byte.tar
- Takes a bunch of files and put them in one file.gzip
- Compress a file.gzip -d
orgunzip
- Uncompress a filewhoami
- tells you who logged in to the system.useradd
- To add the user.userdel
- To delete the user.groupadd
- To add the group.groupdel
- To delete the group.usermod
- To modify the user account.su -
orsudo
- Switches to the Root User.visudo
- Edits the /etc configuration file.who
- tells you how many peoples are logged in the system.id
- gives you detail about a particular user.date
- tells about the date and time.uname
- tells about OS.which
- command tells you where the command is located.ps
- Lists all the processes that are running in the system.top
- By using the top command you can choose which process you want to see first.kill
- Kills the process name/idcrontab
- To schedule the applications and processes.systemctl
- To start/stop/restart the service.iostat
- Prints input/output statistics.df -h
- Prints information about disk partition in human-readable form.netstat
- It will show your internet information about the gateway, subnet mask, etc.reboot
- To reboot your system.
I hope these commands are enough for DevOps Engineers to get much more familiar with Linux.
Git Commands:
1) git --version
- Shows the version of Git that is installed in the system.
2) git config --global user.name "username"
- To authenticate with GitHub by giving a username.
3) git config --global user.email "useremail"
- With a username, you have to provide email Id that is associated with GitHub.
3) git init
- To initialize the git repository.
4) git add .
- To add the file to the working directory.
5) git commit -m "Message"
- To add the file in the staging area with a message.
6) git push
- Pushing the file to the remote repo.
7) git push --set-upstream origin <branch-name>
- To push the files to a particular branch.
8) git checkout -b <branch-name>
- To create a new branch.
9) git branch
- To list all the branches.
10) git branch -d <branch-name>
- To delete the branch.
11) git checkout <branch-name>
- To switch to another branch.
12) git status
- To see the status of the file that they are in the staging area or in the working directory.
13) git log
- Prints the history of all your commits.
14) git clone <URL>
- To clone the project in your local system.
15) git merge <branch-name>
- Merges the branch files with another branch.
16) git revert HEAD --no-edit
- This command will revert (undo) all the changes of your latest commit.
17) git reset --soft HEAD~1
- This command will remove the commit and put the commit in a staging area.
git reset --mixed HEAD~1
- This command will remove the commit as well as brings the commit into unstaging area and moves it to the working directory.git reset --hard HEAD~1
- This is the destructive command because after this you cannot be able to get back as it removes the commit as well as changes from the working directory.
18) git rebase <branch-name>
- This command works the same as merging but in this, but after rebasing the branch it will delete all the history of the rebased branch.
19) git stash
- This command will save all your incomplete works safely.
20) git stash list
- This command will list all your stashed works.
21) git stash drop
- This command will delete the stash files.
22) git stash pop
- Used to reapply the changes in the file.
23) git remote
- To connect the local repo to the remote repo.
This is the end of today's #90DaysOfDevOps challenge. I hope I hadn't missed something.
Hope you all will learn something from this blog. You can connect with me on Twitter (amitmau07)
Follow me on Hashnode for more Linux and DevOps upcoming blogs.
THANK YOU !! :)