1.1. Linux Quick Start Guide¶
1.1.1. Setup¶
To add python to PATH:
export PATH="/C/Users\vkisf\AppData\Local\Programs\Python\Python38:$PATH"
To add python scripts (pytest etc.) to PATH:
export PATH="/C/Users\vkisf\AppData\Local\Programs\Python\Python38\Scripts:$PATH"
To add java to PATH:
export PATH="/C/Users/vkisf/AppData/Local/Programs/AdoptOpenJDK/jdk-11.0.8.10-hotspot/bin:$PATH"
To set an alias: ``alias python38=”winpty /C/UsersvkisfAppDataLocalProgramsPythonPython38python.exe”
To ssh:
alias ssh_server1="ssh username@servername.com"
1.1.2. General¶
To clear terminal window text:
clear
To copy text from terminal: simply highlight the text
To paste text into terminal:
Shift
+Insert
To change directories:
cd folder1/folder2
To back out a directory:
cd ..
then back out 2 and so on:cd ../..
To back out to home directory:
cd ~
To create a directory:
mkdir folder1
To create a file:
touch file.txt
To concatenate 2 files:
cat file1.txt file2.txt > file2.txt
Pipe to a file:
>
To append to a file:
>>
To to print file content to terminal:
cat file1.txt
To execute a file:
./file1.txt
To remove a file:
rm file1.txt
To remove all files under a folder:
rm -rf folder1
To remove a folder:
rmdir folder1
To rename a file/folder:
mv file1.txt file2.txt
To get current working directory:
pwd
To get list of files/folders in your current working directory:
dir -la
orls -la
(-l for long desc, -a for hidden)To search for text in files/folders:
grep -r "text" *
(the “*” is a wild card)
1.1.3. File Permissions¶
To get list of files/folders with permission levels in your current working directory:
dir -la
To change file/folder permissions:
chmod -R u=rwx folder
-R
is recursively change all files/folder under the given folderu
is for “user”,g
for “group”,o
for “other” anda
for “all”r
for “read”,w
for “write”,x
for “execute”
To change group of a file/folder:
chgrp new_groupname file.txt
To check which groups you belong to:
groups
1.1.4. Scripting¶
To print datetime:
date +%m%d%y
(note lower case is short form, upper case is long form)To declare a variable in a script:
variable1 = "this"
and to call it$variable1