The last taskkk .. . on Git, GitHub & Linux!! 🎬

Ashmi SinhaAshmi Sinha
6 min read

Why not make this last blog interesting 🤠

You have completed the Linux & Git-GitHub hands on & I hope you have learned something interesting from it.🙌

Let’s make a well-articulated and documented "cheat sheet" 📝 with all the commands we've learned so far in Linux, Git & GitHub and brief info about its usage.

Let’s show us your knowledge mixed with your creativity😎

Linux

CommandDescription
dateDisplay the current system date and time
hostnameDisplay the hostname of the system
ifconfigDisplay the IP and Mac Address of the system
wDisplay currently logged in users in the system
free -mDisplay free and used memory in the system
lsList all files and directories in the current working directory
ls -laList all files and directories including, hidden files and other information like permissions, size, and owner
cdChange the directory to the home directory
cd ..Change the directory to one level up
cat filenameDisplay the content of the file
cat file1 file2 > file3Combine two files named file1 and file2 and store the output in a new file file3
tail filenameDisplay the last 10 lines of a file
head filenameDisplay the first 10 lines of a file
mv oldfile newfileRename a file
rm filenameDelete a file
mkdir dirnameCreate a directory
rm -rf dirnameRemove a directory
historyPrint a history list of all commands
clearClear the terminal
shutdown -h nowShut down the system
rebootRestart the system

File Permission Commands

CommandDescription
ls -l filenameCheck the current permission of any file
chmod 777 filenameAssign full(read, write, and execute) permission to everyone
chmod -R 777 dirnameAssign full permission to the directory and all sub-directories
chmod 766 filenameAssign full permission to the owner, and read and write permission to group and others
chmod -x filenameRemove the execution permission of any file
chown username filenameChange the ownership of a file
chown user:group filenameChange the owner and group ownership of a file
chown -R user:group dirnameChange the owner and group ownership of the directory and all sub-directories

🎃User and Group Management Commands

CommandDescription
wDisplay all login users
useradd usernameAdd a new user account
userdel -r usernameDelete a user account
usermod [option] usernameChange the user account information including, group, home directory, shell, expiration date
usermod -aG groupname usernameAdd a user to a specific group
groupadd groupnameCreate a new group
groupdel groupnameRemove a group
lastDisplay information of the last login user
idDisplay UID and GID of the current user

👾 Package Management Command

CommandDescription
apt-get install packagenameInstall the package on Debian based distributions
apt-get remove packagenameRemove a package on Debian based distributions
`dpkg -lgrep -i installed`
dpkg -i packagename.debInstall .deb package
apt-get updateUpdate the repository on Debian based distributions
apt-get upgrade packagenameUpgrade a specific package on Debian based distributions
apt-get autoremoveRemove all unwanted packages on Debian based distributions
yum install packagenameInstall the package on RPM-based distributions
yum remove packagenameRemove a package on RPM-based distributions
yum updateUpdate all system packages to the latest version on RPM-based distributions
yum list --installedList all installed packages on RPM-based distributions
yum list --availableList all available packages on RPM-based distributions

Compress and Uncompress Commands

Tar, Zip, and Unzip are the most popular command-line utility in Linux used to compress and uncompress files and directories.

CommandDescription
tar -cvf filename.tar filenameCompress a file in the Tar archive
tar -xvf filename.tarUncompress a Tar file
tar -tvf filename.tarList the content of the Tar file
tar -xvf filename.tar file1.txtUntar a single file from Tar file
tar -rvf filename.tar file2.txtAdd a file to the Tar file
zip filename.zip filenameCompress a single file to a zip
zip filename.zip file1.txt file2.txt file3.txtCompress multiple files to a zip
zip -u filename.zip file4.txtAdd a file to a zip file
zip -d filename.zip file4.txtDelete a file from a zip file
unzip -l filename.zipDisplay the content of zip archive file
unzip filename.zipUnzip a file
unzip filename.zip -d /dirnameUnzip a file to a specific directory

🕊Git

CommandDescription
git initinitialize an existing directory as a Git repository
git statuscheck git status
git add .add all the files
git add [filename]add a specific file as it looks now to your next commit (stage)
git commit -m "[descriptive_message]"commit your staged content with a descriptive message
git remote -vget the URLs of the Push and Fetch of remote repository
git log
(--oneline --pretty)show the commit history for the currently active branch
git config --global user.name "<username>"set a name that is identifiable for credit when review version history
git config --global user.email "<email_id>"set an email address that will be associated with each history marker
git clone [url]retrieve an entire repository from a hosted location via URL
git push [alias] [branch]Transmit local branch commits to the remote repository branch
git remote add [alias] [url]add a git URL as an alias
git stashSave modified and staged changes temporarily
git stash popwrite working from top of the stash stack
git revert [commit hash]used to undo any undesired changes
git diffdiff of what is changed but not staged
git diff --stageddiff of what is staged but not yet committed
git branchlist your branches. a * will appear next to the currently active branch
git branch -b [new_branch]create a new branch at the current commit and switch to that branch
git merge [alias] [branch]merge a remote branch into your current branch to bring it up to date
git fetch [alias]fetch down all the branches from that Git remote
git pullfetch and merge any commits from the tracking remote branch
git rebase [branch]apply any commits of current branch ahead of specified one
git reset --hard [commit hash]clear staging area, rewrite working tree from specified commit

.... I will keep updating this page as I learn more :) STAY TUNED!! 😈

0
Subscribe to my newsletter

Read articles from Ashmi Sinha directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Ashmi Sinha
Ashmi Sinha