Linux commands.
cd - Change directory. Use this command to navigate to different directories in the file system. For example,
cd Documents
will take you to the "Documents" directory.cd ..
Move one level up
cd
To change to a particular directory
cd /
Move to the root directory
ls - List files and directories. This command shows the contents of the current directory. Adding options like
-l
(long format) or-a
(including hidden files) provides more detailed information.ls -R
Lists files in sub-directories as well
ls -a
Lists hidden files as well
ls -al
Lists files and directories with detailed information like permissions,size, owner, etc.
pwd - Print working directory. It displays the path of the current directory you are in.
mkdir - Make directory. Use this command to create a new directory. For example,
mkdir Pictures
will create a directory named "Pictures" in the current location.rm - Remove files or directories. This command deletes files or directories permanently. To remove a file, use
rm filename
. To remove a directory and its contents, userm -r directoryname
.cp - Copy files and directories. Use this command to make copies of files or directories. For example,
cp file.txt /path/to/destination
will copy "file.txt" to the specified destination.mv - Move or rename files and directories. This command is used to move files or directories to a different location or rename them. For example,
mv file.txt /path/to/destination
will move "file.txt" to the specified destination.cat - Concatenate and display file content. This command shows the contents of a file on the terminal. For example,
cat file.txt
will display the content of "file.txt".grep - Search for text within files. Use this command to search for specific text within files. For example,
grep "keyword" file.txt
will search for the keyword in "file.txt".chmod - Change file permissions. This command is used to change the permissions of a file or directory. For example,
chmod +x
script.sh
makes "script.sh" executable.sudo - Execute a command with superuser privileges. Use this command to run a command as the superuser (administrator). It is often used for system administration tasks. For example,
sudo apt-get update
updates the package lists with administrator privileges.apt-get - Package manager command. This command is used to install, update, or remove software packages in Debian-based distributions. For example,
sudo apt-get install package-name
installs a package.man - Access manual pages. This command provides documentation for other commands. For example,
man ls
displays the manual page for the "ls" command.wget - Download files from the web. Use this command to download files from the internet. For example,
wget
https://example.com/file.txt
will download "file.txt" from the specified URL.ping - Check network connectivity. This command is used to check if a network host is reachable. For example,
ping
google.com
will send a network request to Google's servers and show the response time.adduser USERNAME: Adds a new user to the system.
passwd -l USERNAME: Changes the password of a user.
userdel -r USERNAME: Removes a user from the system, including their home.
userdel -r USERNAME: Removes a user from the system, including their home directory.
usermod -a -G GROUPNAME USERNAME: Adds a user to a specific group.
deluser USERNAME GROUPNAME: Removes a user from a specific group.
Git commands.
git init - Initialize a new Git repository. Use this command to start tracking changes in a new project.
git clone [repository URL] - Clone a remote repository. This command creates a copy of a remote repository on your local machine.
git add [file(s)] - Add file changes to the staging area. Use this command to prepare changes for the next commit. For example,
git add file.txt
adds "file.txt" to the staging area.git commit -m "[commit message]" - Commit changes. This command saves the staged changes to the repository with a descriptive commit message. For example,
git commit -m "Added new feature"
commits the changes with the message "Added new feature".git status - Check the status of the repository. This command displays the current status of your files and any pending changes.
git push - Push changes to a remote repository. Use this command to upload your local commits to a remote repository. For example,
git push origin master
pushes the commits to the "master" branch of the remote repository named "origin".git pull - Fetch and merge changes from a remote repository. This command retrieves the latest changes from the remote repository and merges them with your local branch.
git branch - List branches. Use this command to see a list of branches in your repository. The current branch is highlighted with an asterisk.
git checkout [branch name] - Switch branches. This command allows you to switch to a different branch. For example,
git checkout feature-branch
switches to the branch named "feature-branch".git merge [branch name] - Merge branches. Use this command to merge changes from one branch into the current branch. For example,
git merge feature-branch
merges the changes from "feature-branch" into the current branch.git log - View commit history. This command displays a log of all commits in the repository, including commit messages, authors, and timestamps.
git remote add [remote name] [repository URL] - Add a remote repository. This command sets up a connection to a remote repository with a given name and URL. For example,
git remote add origin
https://github.com/user/repo.git
adds a remote repository named "origin" with the specified URL.git remote -v - List remote repositories. Use this command to see a list of remote repositories associated with your local repository.
git stash - Stash changes. This command temporarily saves your changes and reverts the working directory to the last commit, allowing you to switch branches or apply the changes later.
git reset [commit] - Reset the repository to a previous commit. This command undoes commits, discarding changes after the specified commit. Exercise caution with this command, as it modifies the commit history.
*********************************************************************************
I'm glad you found the Linux and Git reference guide helpful! Hope this guide simplifies your experience with Linux and Git. Happy coding and version controlling!
Thank you!