'.88888888:.
88888888.88888.
.8888888888888888.
888888888888888888
88` _`88`_ `88888
88 88 88 88 88888
88_88_::_88_:88888
88:::,::,:::::8888
88`:::::::::'`8888
.88 '::::' '8:88.
8888 `8:888.
.8888' 888888.
.8888:.. .::. ...:'8888888:. _ _
.8888.' :' `':: 88:88888 | (_)
.8888 ' `.888:8888. | |_ _ __ _ ___ __
888:8 . 888:88888 | | | `_ \| | | \ \/ /
.888:88 .: 888:88888: | | | | | | |_| |> <
8888888. :: 88:888888 |_|_|_| |_|\__,_/_/\_\
.::.888. :: .88888888 ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
.::::::.888. :: ::: 8888 .:. ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
'::::::::::.888 ' .::::::::::::' _ _ _
'::::::::::::.8 ' .:8::::::::::::' | | (_) | |
':::mehdi::::::. .:888:::::::::::::' | |_ ___ _ __ _ __ ___ _ _ __ __ _| |
:::::::::::::::88:.__..:88888:::::::::::' | __/ _ \ `__| `_ ` _ \| | `_ \ / _` | |
`'.:::::::::::88888888888.88:::::::::' | || __/ | | | | | | | | | | | (_| | |
`':::_:' -- '' -'-' `':_::::'`' \__\___|_| |_| |_| |_|_|_| |_|\__,_|_|
Thisvrepository named Terminal_Commands, which contains a comprehensive collection of terminal commands and instructions for various tasks related to Git, GitHub, VSCode, Anaconda, and Linux commands.
Configuring user information used across all local repositories
git config --global user.name “[firstname lastname]” | set a name that is identifiable for credit when review version history |
git config --global user.email “[valid-email]” | set an email address that will be associated with each history marker |
git config --global color.ui auto | set automatic command line coloring for Git for easy reviewing |
Configuring user information, initializing and cloning repositories
git init | initialize an existing directory as a Git repository |
git clone [url] | retrieve an entire repository from a hosted location via URL |
Working with snapshots and the Git staging area
git status | show modified files in working directory, staged for your next commit |
git add [file] | add a file as it looks now to your next commit (stage) |
git reset [file] | unstage a file while retaining the changes in working directory |
git diff | diff of what is changed but not staged |
git diff --staged | diff of what is staged but not yet commited |
git commit -m “[descriptive message]” | commit your staged content as a new commit snapshot |
Isolating work in branches, changing context, and integrating changes
git branch | list your branches. a * will appear next to the currently active branch |
git branch [branch-name] | create a new branch at the current commit |
git checkout | switch to another branch and check it out into your working directory |
git merge [branch] | merge the specified branch’s history into the current one |
git log | show all commits in the current branch’s history |
Examining logs, diffs and object information
git log | show the commit history for the currently active branch |
git log branchB..branchA | show the commits on branchA that are not on branchB |
git log --follow [file] | show the commits that changed file, even across renames |
git diff branchB...branchA | show the diff of what is in branchA that is not in branchB |
git show [SHA] | show any object in Git in human-readable format |
Versioning file removes and path changes
git rm [file] | delete the file from project and stage the removal for commit |
git mv [existing-path] [new-path] | change an existing file path and stage the move |
git log --stat -M | show all commit logs with indication of any paths that moved |
Preventing unintentional staging or commiting of files
logs/ *.notes pattern*/ | Save a file with desired paterns as .gitignore with either direct string matches or wildcard globs |
git config --global core.excludesfile [file] | system wide ignore patern for all local repositories |
Retrieving updates from another repository and updating local repos
git remote add [alias] [url] | add a git URL as an alias |
git fetch [alias] | fetch down all the branches from that Git remote |
git merge [alias]/[branch] | merge a remote branch into your current branch to bring it up to date |
git push [alias] [branch] | Transmit local branch commits to the remote repository branch |
git pull | fetch and merge any commits from the tracking remote branch |
Rewriting branches, updating commits and clearing history
git rebase [branch] | apply any commits of current branch ahead of specified one |
git reset --hard [commit] | clear staging area, rewrite working tree from specified commit |
Temporarily store modified, tracked files in order to change branches
git stash | Save modified and staged changes |
git stash list | list stack-order of stashed file changes |
git stash pop | write working from top of stash stack |
git stash drop | discard the changes from top of stash stack |
-
Creating a Repository
To create a new repository on GitHub, go to your profile page and click on the green "New" button.
-
set Git configuration
To set up github on the local git, open your terminal or command prompt and run the following commands:
git config --global user.name “-------” git config --global user.email “------”
-
set Git configuration
To check your github configuration on the local git, run the following commands:
git config --list
-
Cloning a Repository
To clone a repository, open your terminal or command prompt and run the following command:
git clone git@github.com:username/repository.git
-
connect to a remote repository on GitHub
Run this git command to connect your local Git repository to a remote repository on GitHub.
git remote add origin git@github.com:username/repositoryname.git
-
Adding a File to the Repository
To add a file to the repository, first make sure the file is in the correct directory. Then, open your terminal or command prompt and navigate to the directory where the file is located. Finally, run the following command:
git add "filename"
-
Removing a File from the Repository
To remove a file from the repository, first make sure the file is in the correct directory. Then, run the following command:
git rm --cached "filename"
-
Commiting Changes
After adding/removing the file, you can commit the changes to the repository with the following command:
git commit -m "commit message"
-
Pushing Changes to GitHub
To push the changes to the GitHub repository, run the following command:
git push origin master
-
Update your repo to the latest changes
If you already have a local copy of the repository and you want to update it, you can use the git pull command. This command fetches changes from the remote repository and merges them into your local branch.
git pull origin main
git pull git@github.com:username/repository.git master
-
Initializing a new repository
To create a new repository
git init
-
Creating a New Branch
To create a new branch, run the following command:
git checkout -b branchname
-
Switching Between Branches
To switch between branches, run the following command:
git checkout branchname
-
current status of your working directory
This command shows you which files have been modified, staged, or deleted and the brach you are currently on. Additionally, it will show you any conflicts that may have arisen during a merge or rebase.
git status
-
Merging Branches
To merge a branch into the master branch, first switch to the master branch and then run the following command:
git merge branchname
git merge branchname --no-edit -m "commit message"
-
Deleting a Branch
To delete a branch, run the following command:
git branch -d branchname
-
view the commit history
This will display a list of all the commits made to the repository, including the author, date, and commit message.
git log
-
Open VSCode using terminal
To open VSCode simply write:
code
-
Open a file using VSCode
To open a file using VSCode simply write:
code [filename]
-
Installing Anaconda
To install Anaconda, follow these steps:
Download the Anaconda installer for your operating system from the official Anaconda distribution page. Run the installer and follow the on-screen instructions.
-
Create a new environment
To create a new environment, run the following command:
conda create --name myenv
Replace myenv with the name you want to give to your environment.
-
Activate an environment
To activate an environment, run the following command:
conda activate myenv
-
Install packages in the environment
A YAML environment file is a text file that specifies the packages and dependencies for an environment. To use a YAML environment file, create a file named environment.yml with the following content:
name: myenv dependencies: - anaconda - python=3.8 - pip - pip: - package1 - package2
Replace myenv with the name of your environment, and package1 and package2 with the names of the packages you want to install.
-
create an environment using the YAML file
To create an environment from the YAML file, run the following:
conda env create -f environment.yml
-
Updating an Environment
To update an environment from the YAML file, run:
conda env update -f environment.yml
To update an environment, run:
conda update --all --name myenv
Replace myenv with the name of your environment.
-
Viewing a List of Your Environments
To view a list of all your environments, run:
conda env list
This will display a list of all your environments, along with their names and paths.
-
printing working directory
To print the path of the working directory, starting from the root
pwd
-
Creating a New Directory
To create a new directory, run the following command:
mkdir [directoryname]
-
Changing the Current Directory
To change the current directory, run the following command:
cd [directoryname]
To change the current directory to parent directory, run the following command:
cd ..
To change the current directory to root directory, run the following command:
cd .
-
Listing the Contents of a Directory
To list the contents of a directory, run the following command:
ls
To list the contents of a directory in a long listing format, run the following command:
ls -l
To list the contents including hidden content of a directory, run the following command:
ls -a
-
Creating a New File
To create a new file, run the following command:
touch [filename]
-
editing the file
To open and edit a file, run the following command:
vi [filename]
After this press "i" to be able to insert and then press "ESC" to exit inser mode and press "q" to quit and "wq" to write the file and quit.
-
Disk uusage
To analyze and report on disk usage within directories and files, execute the following command:
du [directory/file]
-
Viewing the Contents of a File
To view the contents of a file, run the following command:
cat [filename]
-
copy file
To copy a file, run the following command:
cp [Source_file] [Destination_file] ```bash To copy a folder, run the following command: ```bash cp -r [Source_folder] [Destination_file]
-
Deleting a File or Directory
To delete a file, run the following command:
rm -rf [filename]
To delete a folder, run the following command:
rm -r [foldername]
To delete a directory, run the following command:
rm dir [filename]
-
history of executed command
To view previously executed this command:
history
-
view date and time
To view current date and time executed this command:
date
To view a date manualy use:
-
view calender
To view specific month in a year executed this command:
cal [month][year]
To view current month in a year executed this command:
cal
To view full year executed this command:
cal -y
-
Generate a new SSH key pair
This following command will generate a new SSH key pair. It creates a RSA key pair and saves the private key to a file named "id_rsa" in the "~/.ssh" directory, and it saves the public key to a file named "id_rsa.pub" in the same directory.
ssh-keygen -t rsa
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
This command will generate a new SSH key pair. It creates a 4096-bit RSA key pair and saves the private key to a file named "id_rsa" in the "~/.ssh" directory, and it saves the public key to a file named "id_rsa.pub" in the same directory. The -C flag is used to add a comment, which is useful for identification purposes.
-
Searching for a File or Directory
To search for a file or directory, run the following command:
find / -name "filename" 2>/dev/null
-
Downloading a File
To download a file, run the following command:
wget fileurl
-
Extracting a Zip File
To extract a zip file, run the following command:
unzip [filename.zip]
-
Compressing a Directory
To compress a directory into a zip file, run the following command:
zip -r filename.zip directoryname
-
Moving a File or Directory
To move a file or directory, run the following command:
mv [filename] [destination]
-
Renaming a File or Directory
To rename a file or directory, run the following command:
mv [oldfilename] [newfilename]
-
Updating the System
To update the system, run the following command:
sudo apt-get update && sudo apt-get upgrade
-
Checking the System's Uptime
To check the system's uptime, run the following command:
uptime
-
Creating a Bash File
To create a bash script file with the .sh extension. For example, "my_script.sh" Add a shebang line at the beginning of the script to specify the interpreter. In this case, we will use bash.
#!/user/bin/bash
Write your script commands under the shebang line. Each command should be on a new line. For example, let's print "Hello, World!" and list the files in the current directory.
#!/user/bin/bash echo "Hello, World!" ls
Save your script file.
Open a terminal and navigate to the directory where your script file is located. Give the script file execute permissions by running the following command:
chmod +x my_script.sh chmod u+rwx my_script.sh . . .
removing permission
chmod u-w my_script.sh chmod u-r my_script.sh . . .
Now you can run your script by executing the following command:
./my_script.sh
This will execute your script and display the output in your terminal.
Remember to replace my_script.sh with the actual name of your script file.
- EXAMPLE:
#!/user/bin/bash greeting = "welcome" user = $(whoami) day = $(date + %A) echo "greeting back $user! Today is $day, which is the best day of the entire week!" echo "your bash shell version is $BASH_VERSION. Enjoy!"
- EXAMPLE: