The last taskkk .. . on Git, GitHub & Linux!! 🎬
Ashmi 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
Command | Description |
date | Display the current system date and time |
hostname | Display the hostname of the system |
ifconfig | Display the IP and Mac Address of the system |
w | Display currently logged in users in the system |
free -m | Display free and used memory in the system |
ls | List all files and directories in the current working directory |
ls -la | List all files and directories including, hidden files and other information like permissions, size, and owner |
cd | Change the directory to the home directory |
cd .. | Change the directory to one level up |
cat filename | Display the content of the file |
cat file1 file2 > file3 | Combine two files named file1 and file2 and store the output in a new file file3 |
tail filename | Display the last 10 lines of a file |
head filename | Display the first 10 lines of a file |
mv oldfile newfile | Rename a file |
rm filename | Delete a file |
mkdir dirname | Create a directory |
rm -rf dirname | Remove a directory |
history | Print a history list of all commands |
clear | Clear the terminal |
shutdown -h now | Shut down the system |
reboot | Restart the system |
File Permission Commands
Command | Description |
ls -l filename | Check the current permission of any file |
chmod 777 filename | Assign full(read, write, and execute) permission to everyone |
chmod -R 777 dirname | Assign full permission to the directory and all sub-directories |
chmod 766 filename | Assign full permission to the owner, and read and write permission to group and others |
chmod -x filename | Remove the execution permission of any file |
chown username filename | Change the ownership of a file |
chown user:group filename | Change the owner and group ownership of a file |
chown -R user:group dirname | Change the owner and group ownership of the directory and all sub-directories |
🎃User and Group Management Commands
Command | Description |
w | Display all login users |
useradd username | Add a new user account |
userdel -r username | Delete a user account |
usermod [option] username | Change the user account information including, group, home directory, shell, expiration date |
usermod -aG groupname username | Add a user to a specific group |
groupadd groupname | Create a new group |
groupdel groupname | Remove a group |
last | Display information of the last login user |
id | Display UID and GID of the current user |
👾 Package Management Command
Command | Description |
apt-get install packagename | Install the package on Debian based distributions |
apt-get remove packagename | Remove a package on Debian based distributions |
`dpkg -l | grep -i installed` |
dpkg -i packagename.deb | Install .deb package |
apt-get update | Update the repository on Debian based distributions |
apt-get upgrade packagename | Upgrade a specific package on Debian based distributions |
apt-get autoremove | Remove all unwanted packages on Debian based distributions |
yum install packagename | Install the package on RPM-based distributions |
yum remove packagename | Remove a package on RPM-based distributions |
yum update | Update all system packages to the latest version on RPM-based distributions |
yum list --installed | List all installed packages on RPM-based distributions |
yum list --available | List 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.
Command | Description |
tar -cvf filename.tar filename | Compress a file in the Tar archive |
tar -xvf filename.tar | Uncompress a Tar file |
tar -tvf filename.tar | List the content of the Tar file |
tar -xvf filename.tar file1.txt | Untar a single file from Tar file |
tar -rvf filename.tar file2.txt | Add a file to the Tar file |
zip filename.zip filename | Compress a single file to a zip |
zip filename.zip file1.txt file2.txt file3.txt | Compress multiple files to a zip |
zip -u filename.zip file4.txt | Add a file to a zip file |
zip -d filename.zip file4.txt | Delete a file from a zip file |
unzip -l filename.zip | Display the content of zip archive file |
unzip filename.zip | Unzip a file |
unzip filename.zip -d /dirname | Unzip a file to a specific directory |
🕊Git
Command | Description |
git init | initialize an existing directory as a Git repository |
git status | check 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 -v | get 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 stash | Save modified and staged changes temporarily |
git stash pop | write working from top of the stash stack |
git revert [commit hash] | used to undo any undesired changes |
git diff | diff of what is changed but not staged |
git diff --staged | diff of what is staged but not yet committed |
git branch | list 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 pull | fetch 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