What every newbie in DevOps need to know 2

Alex Izuka
5 min readJan 16, 2022

--

Rerun

We began a series on what every newbie in DevOps needs to know, we discussed what a programming language is, tools for programming, Linux and version control, what is DevOps and DevOps lifecycle, kindly click the link https://aleqxan.medium.com/what-every-newbie-in-devops-need-to-know-e27faa019a2d.

In this article, we would be doing further explanations on Linux, Git, and it’s command as they are necessary for a DevOps engineer.

Linux

We would be doing an extensive explanation about Linux commands. Like we defined in the first article, Linux is an open-source operating system that handles the communication between the software and hardware of a system. The commands are used to locate executable files associated with the given command by searching them in the path environment variable. The PATH environment variable is an important security control that specifies the directories to be searched in a file command.

Linux manages the following;

→ Application installation and configuration

→ Housekeeping of files

→ File backups

→ Disaster recovery and restoration

→ Building new systems

Basic Linux commands

We would be looking at some basic Linux command which you’ll be using daily as a DevOps engineer.

ls      - To list filescd      - Change the current directorysudo    - Change a current user to a root usermkdir   - Create a directorymv      - To move or rename a filerm      - To remove files in a directorychmod   - To change a file modechown   - To change ownership of a filecat     - To view content of a fileecho    - For displaying strings for arguements.clear   - Clears the terminal screenhistory - Shows previous history of commandsapt-get - Package manager used to update softwaretouch   - used to create, change and modify pwd     - To display location of current working directorycp      - Used to copy a file or directoryrename  - Used to rename files

Git and its commands

Before looking at Git commands we would explain what git is all about and its workflow.

Git is a free and open-source distributed version control system designed to handle everything from small to very large projects with speed and efficiency. You might be wondering why people interchangeably used Github and git and if there is a difference between them, Git is a version control system to manage source code history. GitHub is a hosting service for Git repositories. Git enables you to work with other team members on a particular project, allow others to access your project, or store your project for future use. With git, various persons can work on the same project from various locations and on different parts, to sum up to one. Git enables changes to be made on this code regularly and being pushed after changes have been made.

Git workflow

→ Working directory: this is a local physical directory where you make changes to your file.

→ Staging area: this is a place where git keeps a reference of all modifications to be sent in your next commit.

→ Git directory: is a repo that stores all files in a compressed form.

git init - It's used to start a new repositorygit clone [url]- Used to obtain a repository from an existing urlgit add [file] - It adds file to a staging areagit add . - It adds all the filesgit commit - the command records the file in the version histroygit status - get to know status of a filegit rm [file] - Deletes file from your working directorygit branch - list all the local branch in your current directorygit branch [branch name] - creates a new branchgit merge - merges the branch history into current branchgit remote add [variable name] [remote server link] - connects your local repository to local server.git push [variable name] [branch] - sends branch commit to your remote repositorygit pull [repository link] - fetches and makes change on remote server to your working directory

Using command line to push to Git

Create a new repository on Github: Go to your web browser, open www.github.com create an account. Then create a new repository.

Fill up all the required details, i.e., repository name, description, and also make the repository public this time as it is free.

Open your gitbash: To get gitbash click https://git-scm.com/downloads to download. After downloading and installation go to your search button and type ‘gitbash’ then click enter.

Create your local project in your desktop directed towards a current working directory: pwd stands for 'print working directory, which is used to print the current directory.

Move to the specific path in your local computer by cd 'path_name'. The cd commands stand for 'change directory' and it is used to change to the working directory in your operating system, and to locate your file, 'path_name'i.e., C:/Users/Dell/Downloads/FaceDetect-master needs to be given. This command can identify the required file that you are looking to work with.

To initialize your repository: Use git init

Add the file to the new local repository: Use git add . in your bash to add all the files to the given folder. Use git status in your bash to view all the files which are going to be staged to the first commit.

Commit the files staged in your local repository by writing a commit message: You can create a commit message by git commit -m 'your message', which adds the change to the local repository. git commit uses '-m' as a flag for a message to set the commits with the content where the full description is included.

Copy your remote repository’s URL from GitHub: navigate to your github account and copy the URL that you got when you created the repository.

Add the URL copied: then use git remote add origin 'your_url_name'

Push the code in your local repository to GitHub: git push -u origin master

If you carried out all this, you have successfully pushed your code to your Github repository. You can check the status of your commit by using git status

We have successfully taken you through basic Linux and git commands, with this you now know the basics for both and should be able to use them for your projects or practice as a DevOps engineer or a software developer.

There is still much more to come regarding all you need to know as a DevOps engineer, kindly keep a watch on our page; aleqxan.medium.com or twitter.com/aleqxan

--

--

Alex Izuka
Alex Izuka

No responses yet