Table of Contents

  1. Learning how to live in the terminal using Git without using GUI
  2. Pros and Cons of Using Terminal and GUI
  3. Basic Terminal Command Cheat Sheet
  4. Linux Directory Structure
  5. Nano Editor
  6. Vi Editor
  7. Git Command Cheat Sheet
  8. Reasoning behind learning Linux

Learning how to live in the terminal using Git without using GUI.

As a developer, I will be expected to work with and using UNIX systems and the Git version control system that is used by over 90% of the industry. Although I predominantly learned everything on a Windows OS system during my undergraduate studies, I thought I should dip my feet into the basics before moving on to learning actual development. This would in theory, allow me to learn a completely different operating system as well as familiarise myself with the terminal and away from GUI software. I admit using GUI for most of my projects and courseworks such as File Explorer, GitHub Desktop, SourceTree and several others. Therefore, training myself to live in the terminal would help immensely to avoid being overwhelmed when the time arises to use them. Being “terminal savvy” is to be expected for seasoned developers which may not come as a surprise to many.

There are several VCS that are popular but none of them comes close to Git. I have experience with Subversion using TortoiseSVN as the GUI software during my internship at Finexus. It is a completely different type of VCS as it is a centralised system rather than a distributed system like Git or Mercurial. Git has several GUI that facilitate the need for an interactable interface for several reasons I will mention later. Popular Git GUI clients such as GitHub Desktop, GitKraken, Sublime and the one I am familiar with, Sourcetree, all serve the same purpose to provide tooling to use Git through an interface.

Pros and Cons of Using Terminal and GUI

Terminal

Pros:

  • Terminal commands can be quicker to use than GUI once you're familiar with them.
  • Allows for more complex commands and scripting. This can automate repetitive tasks.
  • Offers more control over the system and software.

Cons:

  • Can be difficult for beginners to learn.
  • Unlike GUI, Terminal doesn't provide visual feedback, which might make it harder to understand what's happening.

GUI

Pros:

  • Generally more intuitive and easier for beginners to use.
  • Provide visual representations making it easier to understand the structure and state of things.
  • No need to remember specific commands as functions are represented visually.

Cons:

  • Navigating through GUI can be slower than using Terminal commands.
  • GUIs might not offer all the functionality that Terminal does.

Basic Terminal Command Cheat Sheet

CommandExplanationExample
lsShow a list of files in the current directory that I am on/ pointing at.ls Downloads
ls Downloads/file
start/openOpen the File Explorer at this current location.start .
clearClear the terminal.
pwdPrint the current working directory/location/path.
cdChange directory to the one I am pointing at.cd Downloads
touchCreate a file/ updating a filetouch test.txt
touch Downloads/okay.py
mkdirMake a directory.mkdir New File
rmdirRemove a directory.
rmRemove file.rm test.txt
rm Okay.py
rm -rfRemove directory.rm Image
catConcatenate and displays files.cat file
tacDisplays files in reverse order.
man Display manual/documentation for commandsman ls
man -k Ask for help with a search term for a command.man -k calendar
exitExits the shell from the current session.
echoDisplay a line of text.echo $PATH
whichShows the full path of commands.which cat (first one that appears in the directory will be the result)
.Execute a program..game
-aIndicates all.
-lUse a list format.
-FReveal file types by appending a character to the end of the file.ls -F
-dList directory names and not the contents.
-rReverse the order of the result.
-RList files recursively.
-tSort by time, most recent first.
find Recursively finds files in the path that match the expression.
find -name Find files and directories that match the pattern
find -iname Ignores case.
find -mtime Finds files that are days old.
find -size Finds file that are of size num
find -newer Find files that are newer than file
find -exec {} ;Run command against all the files that are found
locate Lists files that match the pattern. Is faster than find command but the results are not in real time. Queries an index.
uptimeShows when the system was booted and how long it has been up.
cat Display the contents of the file.
more Browse through a text file.
less More features than more.
head Output the beginning portion of the file.head -f

-f follows the file | | tail | Output the bottom portion of the file. | tail -n

Where n is the number of lines |

SymbolTypePermissionFileDirectory
/ or dDirectory
@Link
*Executable
lSymbolic Link
-Regular File
rReadAllows a file to be readAllows file names in the directory to be read.
wWriteAllows a file to be modifiedAllows entries to be modified within the directory.
xExecuteAllows the execution of a fileAllows access to contents and metadata for entries.
uUser
gGroup
oOther
aAll
chmodChange Mode Command
ugoaUser Category
+-=Add subtract and set permissions

Reading File and Directory Permissions

TypeUserGroupOtherNumber of LinksOwner NameGroup NameNumber of bytes in the fileLast Modification TimeFile Name
-rw-r—r—1bobusers10400Sep 27 08:52sales.data
OctalBinaryStringDescription
00- - -No permissions
11- - xExecute only
210-w-Write only
311-wxWrite and Execute
4100r- -Read only
5101r-xRead and execute
6110rw-Read and write
7111rwxRead, write and execute

Commonly Used Permissions

SymbolicOctalDescription
-rwx- - - - - -700Read edited and executed only by the owner.
-rwxr-xr-x755Anyone on the system can execute it but only the owner can read and edit it.
-rw-rw-r- -664Allow a group to edit the file and allow others to read it.
-rw-rw- - - -660Allow a group to edit the file and but don’t allow others to read it.
-rw-r- - r- -644Allow all the users to read the file but only the owner can edit and use it.

Linux Directory Structure

Containers for other files or other directories. These containers are arranged in a tree-like structure that each can be accessed by their name or a shortcut to the position.

Directories/FoldersPurpose
/Root folder
/binBinaries and other exe programs
/etcSystem config files
/homeHome directories
/optOptional/3rd-party software
/tmpTemporary folders that are cleared on reboot
/varVariable data, log files
/exportShared file systems
/libSystem Libraries
/lib64System Libraries, 64bit
/lost+foundUsed to store recovered files
/mediaUsed to mount removable media
/mntUsed to mount external file systems
/procProvides info of currently running processes
/rootHome directory for root account
/sbinSystem administration binaries
/selinuxUsed to display information about SELinux
/srvData served by the system
/srv/wwwWeb server files
/srv/ftpFile Transfer Protocol (FTP) files
/sysUsed to display and configure devices known to Linux kernel
/usrUser related programs
/usr/binBinaries and executable programs
/usr/libLibraries
/usr/localLocally installed software

| /usr/local/crashplan/

bin etc lib log | Application Directory |

Nano Editor

Simple editor that is relatively easy to pickup but with lesser features than vi or emacs.

CTRL + G for more information when in the nano editor. To enter the nano editor;

nano file.txt

Vi Editor

Steeper learning curve that may not be as intuitive but in return, offers more powerful features.

vi file.txt #Start editing the file
vim file.txt #Vi but with more features
view fil.txt #Starts vim in view mode

Vi Command Mode and Navigation

KeyFunction
kUp one Line
jDown one line
hLeft one character
lRight one character
wRight one word
bLeft one word
^Go to beginning of line
$Go to end of line

Git Command Cheat Sheet

Command/TerminologyExplanationExample
HEADLatest commit of the current branch the user is on.HEAD → Main
HEAD → Feature/030524
master/mainStarting branch/trunk of the repository
git statusCheck if there’s a current repository in this directory.
git initInitialise a new git repository.
git addAdd the changes/specific files that can be separated to stage for a commit from working directory.git add characters.txt
git commitProvide message for commit to summarise the changes done.git commit -m “message”
git commit -a -m “message”Commit all unstaged files
git logReturn a log of commits done by every contributing collaborator.
git log —onelineReturn a simplified log with only the commit message.
git commit —amendEdit the previous commit message done.
git branchView existing branches in the report. * shows the branch that the user is currently on.
git branch Create a branch but does not change the current branch.git branch bugfix
git checkoutDoes the same as git switch but also more.
git switch -c Create a branch and changes to the branch.git switch -c bugfix
git switch Switches to the pointed branch.git switch bugfix
git branch -d Delete the selected branch. If you are currently on the branch it cannot be deleted. Switch to another branch before deleting this branch.git branch -d deleteMe
git branch -D Force delete a branch even if it is not fully merged with its parent branch.git branch -D deleteMe
git branch -m Move/rename a branch by being on the branch first.git branch -m newName
git merge Switch to the target branch to be merged into and use the command.

Reasoning behind learning Linux

Linux is a highly flexible and customizable operating system, allowing developers to alter its code to meet their specific needs. This is a major advantage over PowerShell, which is not open-source and therefore not as flexible. Another advantage is efficiency. Linux is known for its efficient use of system resources, making it perform faster and more smoothly than many other operating systems. This is especially important for developers who often run complex tasks that can be resource-intensive.

Furthermore, Linux has a strong community of users and developers who actively maintain and update its software. This means that new features, improvements, and security patches are constantly being added. It also means that help and support are readily available, which can be crucial when encountering a problem or learning something new. Linux is popular in the server space because it's free and has a lower total cost of ownership compared to other operating systems. It's often the go-to choice for web servers, making it an important skill for web developers.