SlideShare ist ein Scribd-Unternehmen logo
1 von 7
Downloaden Sie, um offline zu lesen
freeworld.posterous.com
Linux Bash Shell
Cheat Sheet
(works with about every distribution, except for apt-get which is Ubuntu/Debian exclusive)
Legend:
Everything in “<>” is to be replaced, ex: <fileName> --> iLovePeanuts.txt
Don't include the '=' in your commands
'..' means that more than one file can be affected with only one command ex: rm
file.txt file2.txt movie.mov .. ..
Linux Bash Shell Cheat Sheet
Basic Commands
Basic Terminal Shortcuts Basic file manipulation
CTRL L = Clear the terminal cat <fileName> = show content of file
CTRL D = Logout (less, more)
SHIFT Page Up/Down = Go up/down the terminal head = from the top
CTRL A = Cursor to start of line -n <#oflines> <fileName>
CTRL E = Cursor the end of line
CTRL U = Delete left of the cursor tail = from the bottom
CTRL K = Delete right of the cursor -n <#oflines> <fileName>
CTRL W = Delete word on the left
CTRL Y = Paste (after CTRL U,K or W) mkdir = create new folder
TAB = auto completion of file or command mkdir myStuff ..
CTRL R = reverse search history mkdir myStuff/pictures/ ..
!! = repeat last command
CTRL Z = stops the current command (resume with fg in foreground or bg in background) cp image.jpg newimage.jpg = copy and rename a file
Basic Terminal Navigation cp image.jpg <folderName>/ = copy to folder
cp image.jpg folder/sameImageNewName.jpg
ls -a = list all files and folders cp -R stuff otherStuff = copy and rename a folder
ls <folderName> = list files in folder cp *.txt stuff/ = copy all of *<file type> to folder
ls -lh = Detailed list, Human readable
ls -l *.jpg = list jpeg files only mv file.txt Documents/ = move file to a folder
ls -lh <fileName> = Result for file only mv <folderName> <folderName2> = move folder in folder
mv filename.txt filename2.txt = rename file
cd <folderName> = change directory mv <fileName> stuff/newfileName
if folder name has spaces use “ “ mv <folderName>/ .. = move folder up in hierarchy
cd / = go to root
cd .. = go up one folder, tip: ../../../ rm <fileName> .. = delete file (s)
rm -i <fileName> .. = ask for confirmation each file
du -h: Disk usage of folders, human readable rm -f <fileName> = force deletion of a file
du -ah: “ “ “ files & folders, Human readable rm -r <foldername>/ = delete folder
du -sh: only show disc usage of folders
touch <fileName> = create or update a file
pwd = print working directory
ln file1 file2 = physical link
man <command> = shows manual (RTFM) ln -s file1 file2 = symbolic link
Linux Bash Shell Cheat Sheet
Basic Commands
Researching Files Extract, sort and filter data
The slow method (sometimes very slow): grep <someText> <fileName> = search for text in file
-i = Doesn't consider uppercase words
locate <text> = search the content of all the files -I = exclude binary files
locate <fileName> = search for a file grep -r <text> <folderName>/ = search for file names
sudo updatedb = update database of files with occurrence of the text
find = the best file search tool (fast) With regular expressions:
find -name “<fileName>”
find -name “text” = search for files who start with the word text grep -E ^<text> <fileName> = search start of lines
find -name “*text” = “ “ “ “ end “ “ “ “ with the word text
grep -E <0-4> <fileName> =shows lines containing numbers 0-4
Advanced Search: grep -E <a-zA-Z> <fileName> = retrieve all lines
with alphabetical letters
Search from file Size (in ~)
find ~ -size +10M = search files bigger than.. (M,K,G) sort = sort the content of files
sort <fileName> = sort alphabetically
Search from last access sort -o <file> <outputFile> = write result to a file
find -name “<filetype>” -atime -5 sort -r <fileName> = sort in reverse
('-' = less than, '+' = more than and nothing = exactly) sort -R <fileName> = sort randomly
sort -n <fileName> = sort numbers
Search only files or directory’s
find -type d --> ex: find /var/log -name "syslog" -type d wc = word count
find -type f = files wc <fileName> = nbr of line, nbr of words, byte size
-l (lines), -w (words), -c (byte size), -m
More info: man find, man locate (number of characters)
cut = cut a part of a file
-c --> ex: cut -c 2-5 names.txt
(cut the characters 2 to 5 of each line)
-d (delimiter) (-d & -f good for .csv files)
-f (# of field to cut)
more info: man cut, man sort, man grep
Linux Bash Shell Cheat Sheet
Basic Commands
Time settings (continued)
date = view & modify time (on your computer) crontab = execute a command regularly
-e = modify the crontab
View: -l = view current crontab
date “+%H” --> If it's 9 am, then it will show 09 -r = delete you crontab
date “+%H:%M:%Ss” = (hours, minutes, seconds) In crontab the syntax is
%Y = years <Minutes> <Hours> <Day of month> <Day of week (0-6,
Modify: 0 = Sunday)> <COMMAND>
MMDDhhmmYYYY
Month | Day | Hours | Minutes | Year ex, create the file movies.txt every day at 15:47:
47 15 * * * touch /home/bob/movies.txt
sudo date 031423421997 = March 14th
1997, 23:42 * * * * * --> every minute
at 5:30 in the morning, from the 1st
to 15th
each month:
Execute programs at another time 30 5 1-15 * *
at midnight on Mondays, Wednesdays and Thursdays:
use 'at' to execute programs in the future 0 0 * * 1,3,4
every two hours:
Step 1, write in the terminal: at <timeOfExecution> ENTER 0 */2 * * *
ex --> at 16:45 or at 13:43 7/23/11 (to be more precise) every 10 minutes Monday to Friday:
or after a certain delay: */10 * * * 1-5
at now +5 minutes (hours, days, weeks, months, years)
Step 2: <ENTER COMMAND> ENTER Execute programs in the background
repeat step 2 as many times you need
Step 3: CTRL D to close input Add a '&' at the end of a command
ex --> cp bigMovieFile.mp4 &
atq = show a list of jobs waiting to be executed
nohup: ignores the HUP signal when closing the console
atrm = delete a job n°<x> (process will still run if the terminal is closed)
ex (delete job #42) --> atrm 42 ex --> nohup cp bigMovieFile.mp4
sleep = pause between commands jobs = know what is running in the background
with ';' you can chain commands, ex: touch file; rm file
you can make a pause between commands (minutes, hours, days) fg = put a background process to foreground
ex --> touch file; sleep 10; rm file <-- 10 seconds ex: fg (process 1), f%2 (process 2) f%3, ...
Linux Bash Shell Cheat Sheet
Basic Commands
Process Management Create and modify user accounts
w = who is logged on and what they are doing sudo adduser bob = root creates new user
sudo passwd <AccountName> = change a user's password
tload = graphic representation of system load average sudo deluser <AccountName> = delete an account
(quit with CTRL C)
addgroup friends = create a new user group
ps = Static process list delgroup friends = delete a user group
-ef --> ex: ps -ef | less
-ejH --> show process hierarchy usermod -g friends <Account> = add user to a group
-u --> process's from current user usermod -g bob boby = change account name
usermod -aG friends bob = add groups to a user with-
top = Dynamic process list out loosing the ones he's already in
While in top:
• q to close top File Permissions
• h to show the help
• k to kill a process chown = change the owner of a file
ex --> chown bob hello.txt
CTRL C to top a current terminal process chown user:bob report.txt = changes the user owning
report.txt to 'user' and the group owning it to 'bob'
kill = kill a process -R = recursively affect all the sub folders
You need the PID # of the process ex --> chown -R bob:bob /home/Daniel
ps -u <AccountName> | grep <Application>
Then chmod = modify user access/permission – simple way
kill <PID> .. .. .. u = user
kill -9 <PID> = violent kill g = group
o = other
killall = kill multiple process's
ex --> killall locate d = directory (if element is a directory)
l = link (if element is a file link)
extras: r = read (read permissions)
sudo halt <-- to close computer w = write (write permissions)
sudo reboot <-- to reboot x = eXecute (only useful for scripts and
programs)
Linux Bash Shell Cheat Sheet
Basic Commands
File Permissions (continued) Flow Redirection (continued)
'+' means add a right terminal output:
'-' means delete a right Alex
'=' means affect a right Cinema
Code
ex --> chmod g+w someFile.txt Game
(add to current group the right to modify someFile.txt) Ubuntu
more info: man chmod Another example --> wc -m << END
Flow redirection Chain commands
Redirect results of commands: '|' at the end of a command to enter another one
ex --> du | sort -nr | less
'>' at the end of a command to redirect the result to a file
ex --> ps -ejH > process.txt Archive and compress data
'>>' to redirect the result to the end of a file
Archive and compress data the long way:
Redirect errors:
Step 1, put all the files you want to compress in
'2>' at the end of the command to redirect the result to a file the same folder: ex --> mv *.txt folder/
ex --> cut -d , -f 1 file.csv > file 2> errors.log
'2>&1' to redirect the errors the same way as the standard output Step 2, Create the tar file:
tar -cvf my_archive.tar folder/
Read progressively from the keyboard -c : creates a .tar archive
-v : tells you what is happening (verbose)
<Command> << <wordToTerminateInput> -f : assembles the archive into one file
ex --> sort << END <-- This can be anything you want
> Hello Step 3.1, create gzip file (most current):
> Alex gzip my_archive.tar
> Cinema to decompress: gunzip my_archive.tar.gz
> Game
> Code Step 3.2, or create a bzip2 file (more powerful but slow):
> Ubuntu bzip2 my_archive.tar
> END to decompress: bunzip2 my_archive.tar.bz2
Linux Bash Shell Cheat Sheet
Basic Commands
Archive and compress data (continued) Installing software
step 4, to decompress the .tar file: When software is available in the repositories:
tar -xvf archive.tar archive.tar sudo apt-get install <nameOfSoftware>
ex--> sudo apt-get install aptitude
Archive and compress data the fast way:
If you download it from the Internets in .gz format
gzip: tar -zcvf my_archive.tar.gz folder/ (or bz2) - “Compiling from source”
decompress: tar -zcvf my_archive.tar.gz Documents/ Step 1, create a folder to place the file:
mkdir /home/username/src <-- then cd to it
bzip2: tar -jcvf my_archive.tar.gz folder/
decompress: tar -jxvf archive.tar.bz2 Documents/ Step 2, with 'ls' verify that the file is there
(if not, mv ../file.tar.gz /home/username/src/)
Show the content of .tar, .gz or .bz2 without decompressing it:
Step 3, decompress the file (if .zip: unzip <file>)
gzip: <--
gzip -ztf archive.tar.gz Step 4, use 'ls', you should see a new directory
bzip2: Step 5, cd to the new directory
bzip2 -jtf archive.tar.bz2 Step 6.1, use ls to verify you have an INSTALL file,
tar: then: more INSTALL
tar -tf archive.tar If you don't have an INSTALL file:
Step 6.2, execute ./configure <-- creates a makefile
tar extra: Step 6.2.1, run make <-- builds application binaries
tar -rvf archive.tar file.txt = add a file to the .tar Step 6.2.2 : switch to root --> su
Step 6.2.3 : make install <-- installs the software
You can also directly compress a single file and view the file Step 7, read the readme file
without decompressing:
Step 1, use gzip or bzip2 to compress the file:
gzip numbers.txt
Step 2, view the file without decompressing it:
zcat = view the entire file in the console (same as cat)
zmore = view one screen at a time the content of the file (same as more)
zless = view one line of the file at a time (same as less)

Weitere ähnliche Inhalte

Kürzlich hochgeladen

Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...KokoStevan
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfChris Hunter
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 

Kürzlich hochgeladen (20)

Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 

Empfohlen

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Empfohlen (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Bash cheat sheet

  • 1. freeworld.posterous.com Linux Bash Shell Cheat Sheet (works with about every distribution, except for apt-get which is Ubuntu/Debian exclusive) Legend: Everything in “<>” is to be replaced, ex: <fileName> --> iLovePeanuts.txt Don't include the '=' in your commands '..' means that more than one file can be affected with only one command ex: rm file.txt file2.txt movie.mov .. ..
  • 2. Linux Bash Shell Cheat Sheet Basic Commands Basic Terminal Shortcuts Basic file manipulation CTRL L = Clear the terminal cat <fileName> = show content of file CTRL D = Logout (less, more) SHIFT Page Up/Down = Go up/down the terminal head = from the top CTRL A = Cursor to start of line -n <#oflines> <fileName> CTRL E = Cursor the end of line CTRL U = Delete left of the cursor tail = from the bottom CTRL K = Delete right of the cursor -n <#oflines> <fileName> CTRL W = Delete word on the left CTRL Y = Paste (after CTRL U,K or W) mkdir = create new folder TAB = auto completion of file or command mkdir myStuff .. CTRL R = reverse search history mkdir myStuff/pictures/ .. !! = repeat last command CTRL Z = stops the current command (resume with fg in foreground or bg in background) cp image.jpg newimage.jpg = copy and rename a file Basic Terminal Navigation cp image.jpg <folderName>/ = copy to folder cp image.jpg folder/sameImageNewName.jpg ls -a = list all files and folders cp -R stuff otherStuff = copy and rename a folder ls <folderName> = list files in folder cp *.txt stuff/ = copy all of *<file type> to folder ls -lh = Detailed list, Human readable ls -l *.jpg = list jpeg files only mv file.txt Documents/ = move file to a folder ls -lh <fileName> = Result for file only mv <folderName> <folderName2> = move folder in folder mv filename.txt filename2.txt = rename file cd <folderName> = change directory mv <fileName> stuff/newfileName if folder name has spaces use “ “ mv <folderName>/ .. = move folder up in hierarchy cd / = go to root cd .. = go up one folder, tip: ../../../ rm <fileName> .. = delete file (s) rm -i <fileName> .. = ask for confirmation each file du -h: Disk usage of folders, human readable rm -f <fileName> = force deletion of a file du -ah: “ “ “ files & folders, Human readable rm -r <foldername>/ = delete folder du -sh: only show disc usage of folders touch <fileName> = create or update a file pwd = print working directory ln file1 file2 = physical link man <command> = shows manual (RTFM) ln -s file1 file2 = symbolic link
  • 3. Linux Bash Shell Cheat Sheet Basic Commands Researching Files Extract, sort and filter data The slow method (sometimes very slow): grep <someText> <fileName> = search for text in file -i = Doesn't consider uppercase words locate <text> = search the content of all the files -I = exclude binary files locate <fileName> = search for a file grep -r <text> <folderName>/ = search for file names sudo updatedb = update database of files with occurrence of the text find = the best file search tool (fast) With regular expressions: find -name “<fileName>” find -name “text” = search for files who start with the word text grep -E ^<text> <fileName> = search start of lines find -name “*text” = “ “ “ “ end “ “ “ “ with the word text grep -E <0-4> <fileName> =shows lines containing numbers 0-4 Advanced Search: grep -E <a-zA-Z> <fileName> = retrieve all lines with alphabetical letters Search from file Size (in ~) find ~ -size +10M = search files bigger than.. (M,K,G) sort = sort the content of files sort <fileName> = sort alphabetically Search from last access sort -o <file> <outputFile> = write result to a file find -name “<filetype>” -atime -5 sort -r <fileName> = sort in reverse ('-' = less than, '+' = more than and nothing = exactly) sort -R <fileName> = sort randomly sort -n <fileName> = sort numbers Search only files or directory’s find -type d --> ex: find /var/log -name "syslog" -type d wc = word count find -type f = files wc <fileName> = nbr of line, nbr of words, byte size -l (lines), -w (words), -c (byte size), -m More info: man find, man locate (number of characters) cut = cut a part of a file -c --> ex: cut -c 2-5 names.txt (cut the characters 2 to 5 of each line) -d (delimiter) (-d & -f good for .csv files) -f (# of field to cut) more info: man cut, man sort, man grep
  • 4. Linux Bash Shell Cheat Sheet Basic Commands Time settings (continued) date = view & modify time (on your computer) crontab = execute a command regularly -e = modify the crontab View: -l = view current crontab date “+%H” --> If it's 9 am, then it will show 09 -r = delete you crontab date “+%H:%M:%Ss” = (hours, minutes, seconds) In crontab the syntax is %Y = years <Minutes> <Hours> <Day of month> <Day of week (0-6, Modify: 0 = Sunday)> <COMMAND> MMDDhhmmYYYY Month | Day | Hours | Minutes | Year ex, create the file movies.txt every day at 15:47: 47 15 * * * touch /home/bob/movies.txt sudo date 031423421997 = March 14th 1997, 23:42 * * * * * --> every minute at 5:30 in the morning, from the 1st to 15th each month: Execute programs at another time 30 5 1-15 * * at midnight on Mondays, Wednesdays and Thursdays: use 'at' to execute programs in the future 0 0 * * 1,3,4 every two hours: Step 1, write in the terminal: at <timeOfExecution> ENTER 0 */2 * * * ex --> at 16:45 or at 13:43 7/23/11 (to be more precise) every 10 minutes Monday to Friday: or after a certain delay: */10 * * * 1-5 at now +5 minutes (hours, days, weeks, months, years) Step 2: <ENTER COMMAND> ENTER Execute programs in the background repeat step 2 as many times you need Step 3: CTRL D to close input Add a '&' at the end of a command ex --> cp bigMovieFile.mp4 & atq = show a list of jobs waiting to be executed nohup: ignores the HUP signal when closing the console atrm = delete a job n°<x> (process will still run if the terminal is closed) ex (delete job #42) --> atrm 42 ex --> nohup cp bigMovieFile.mp4 sleep = pause between commands jobs = know what is running in the background with ';' you can chain commands, ex: touch file; rm file you can make a pause between commands (minutes, hours, days) fg = put a background process to foreground ex --> touch file; sleep 10; rm file <-- 10 seconds ex: fg (process 1), f%2 (process 2) f%3, ...
  • 5. Linux Bash Shell Cheat Sheet Basic Commands Process Management Create and modify user accounts w = who is logged on and what they are doing sudo adduser bob = root creates new user sudo passwd <AccountName> = change a user's password tload = graphic representation of system load average sudo deluser <AccountName> = delete an account (quit with CTRL C) addgroup friends = create a new user group ps = Static process list delgroup friends = delete a user group -ef --> ex: ps -ef | less -ejH --> show process hierarchy usermod -g friends <Account> = add user to a group -u --> process's from current user usermod -g bob boby = change account name usermod -aG friends bob = add groups to a user with- top = Dynamic process list out loosing the ones he's already in While in top: • q to close top File Permissions • h to show the help • k to kill a process chown = change the owner of a file ex --> chown bob hello.txt CTRL C to top a current terminal process chown user:bob report.txt = changes the user owning report.txt to 'user' and the group owning it to 'bob' kill = kill a process -R = recursively affect all the sub folders You need the PID # of the process ex --> chown -R bob:bob /home/Daniel ps -u <AccountName> | grep <Application> Then chmod = modify user access/permission – simple way kill <PID> .. .. .. u = user kill -9 <PID> = violent kill g = group o = other killall = kill multiple process's ex --> killall locate d = directory (if element is a directory) l = link (if element is a file link) extras: r = read (read permissions) sudo halt <-- to close computer w = write (write permissions) sudo reboot <-- to reboot x = eXecute (only useful for scripts and programs)
  • 6. Linux Bash Shell Cheat Sheet Basic Commands File Permissions (continued) Flow Redirection (continued) '+' means add a right terminal output: '-' means delete a right Alex '=' means affect a right Cinema Code ex --> chmod g+w someFile.txt Game (add to current group the right to modify someFile.txt) Ubuntu more info: man chmod Another example --> wc -m << END Flow redirection Chain commands Redirect results of commands: '|' at the end of a command to enter another one ex --> du | sort -nr | less '>' at the end of a command to redirect the result to a file ex --> ps -ejH > process.txt Archive and compress data '>>' to redirect the result to the end of a file Archive and compress data the long way: Redirect errors: Step 1, put all the files you want to compress in '2>' at the end of the command to redirect the result to a file the same folder: ex --> mv *.txt folder/ ex --> cut -d , -f 1 file.csv > file 2> errors.log '2>&1' to redirect the errors the same way as the standard output Step 2, Create the tar file: tar -cvf my_archive.tar folder/ Read progressively from the keyboard -c : creates a .tar archive -v : tells you what is happening (verbose) <Command> << <wordToTerminateInput> -f : assembles the archive into one file ex --> sort << END <-- This can be anything you want > Hello Step 3.1, create gzip file (most current): > Alex gzip my_archive.tar > Cinema to decompress: gunzip my_archive.tar.gz > Game > Code Step 3.2, or create a bzip2 file (more powerful but slow): > Ubuntu bzip2 my_archive.tar > END to decompress: bunzip2 my_archive.tar.bz2
  • 7. Linux Bash Shell Cheat Sheet Basic Commands Archive and compress data (continued) Installing software step 4, to decompress the .tar file: When software is available in the repositories: tar -xvf archive.tar archive.tar sudo apt-get install <nameOfSoftware> ex--> sudo apt-get install aptitude Archive and compress data the fast way: If you download it from the Internets in .gz format gzip: tar -zcvf my_archive.tar.gz folder/ (or bz2) - “Compiling from source” decompress: tar -zcvf my_archive.tar.gz Documents/ Step 1, create a folder to place the file: mkdir /home/username/src <-- then cd to it bzip2: tar -jcvf my_archive.tar.gz folder/ decompress: tar -jxvf archive.tar.bz2 Documents/ Step 2, with 'ls' verify that the file is there (if not, mv ../file.tar.gz /home/username/src/) Show the content of .tar, .gz or .bz2 without decompressing it: Step 3, decompress the file (if .zip: unzip <file>) gzip: <-- gzip -ztf archive.tar.gz Step 4, use 'ls', you should see a new directory bzip2: Step 5, cd to the new directory bzip2 -jtf archive.tar.bz2 Step 6.1, use ls to verify you have an INSTALL file, tar: then: more INSTALL tar -tf archive.tar If you don't have an INSTALL file: Step 6.2, execute ./configure <-- creates a makefile tar extra: Step 6.2.1, run make <-- builds application binaries tar -rvf archive.tar file.txt = add a file to the .tar Step 6.2.2 : switch to root --> su Step 6.2.3 : make install <-- installs the software You can also directly compress a single file and view the file Step 7, read the readme file without decompressing: Step 1, use gzip or bzip2 to compress the file: gzip numbers.txt Step 2, view the file without decompressing it: zcat = view the entire file in the console (same as cat) zmore = view one screen at a time the content of the file (same as more) zless = view one line of the file at a time (same as less)