Harder, Better, Faster, Stronger - PowerPoint PPT Presentation

1 / 30
About This Presentation
Title:

Harder, Better, Faster, Stronger

Description:

Add to Nautilus Menu (Gnome) The easiest way is to just add the script into ... You can also install the nautilus-actions package and use it to create your own ... – PowerPoint PPT presentation

Number of Views:98
Avg rating:3.0/5.0
Slides: 31
Provided by: corype9
Category:

less

Transcript and Presenter's Notes

Title: Harder, Better, Faster, Stronger


1
Harder, Better, Faster, Stronger
  • Basic tricks and tools to help improve the basic
    Linux user's experience
  • By Cory Peterson

2
Overview
  • Improving Boot Time
  • Bash Shortcuts and tricks
  • Scripting
  • Cronjobs

3
Improving Boot Times
  • Bootchart
  • Readahead
  • Profiling

4
Bootchart
  • Bootchart is a daemon that runs at startup and
    records timing for all processes that run on
    startup
  • Using this tool, you can isolate which processes
    are taking the most time, and help to streamline
    the boot process

5
Beginning Boot
6
After Profiling and Tweaks
7
After Editing rc.sysinit
8
Boot Times
  • Fastest way to decrease boot times is to turn off
    services at startup (sysV-rc-conf for ubuntu,
    system-config-services for fedora)
  • Make sure readahead is running and do a profile
    on boot (must be redone after every new kernel)
    by adding profile to the end of the grub boot
    parameters

9
Editing rc.sysinit
  • Caution! You can render the system unbootable if
    you screw this file up, so keep a live cd handy
    and backup the file before you start
  • Go through the file and find items that you may
    not be using, such as LVM and RAID. Comment out
    the unnecessary issues and then try booting again

10
Parallel Daemons
  • As Zach stated on the mailing list, another way
    to reduce boot time is to initiate parallel
    daemon startup. Adding '' to the end of 'i
    start' may seem like a good idea, but it ignores
    process dependencies and can make hardware not
    respond correctly
  • The correct way involves 'make' and a lot more
    work (i won't be covering this section, maybe
    later on the mailing list)

11
Filesystem Checks
  • One other sticking point that may cause longer
    boot times is the periodic filesystem checks
  • You can make these less frequent by using the
    tool 'tune2fs'
  • This tool allows you to specify the boot times
    between checks

12
Command Line Tricks
  • First we'll start out with some basic tricks in
    case people don't know them
  • Tab autocompletion, reusing previous commands
  • One helpful tool is input/output redirection
  • Using lt and gt you can redirect the input and
    output of any command.

13
Examples
  • lspci gt pci_list.txt causes the output of the
    lspci command to be written to a file named
    pci_list.txt
  • You can also do multiple input redirection, such
    as combining two files to output into one
  • cat lt(cat file1.txt) lt(cat file2.txt) gt
    combined.txt

14
Combining Multiple Commands
  • You can also specify multiple items in commands,
    take for instance removing 3 folders. You could
    use
  • rm -rf /folder1
  • rm -rf /folder2
  • rm -rf /folder3
  • Or just use
  • rm -rf /folder1,folder2,folder3

15
Aliases
  • Another helpful trick is the use of aliases.
    Using aliases for commonly used commands can help
    reduce typing time.
  • If you always want ls to output the full details
    of all files, typing ls -al is more typing than
    needed.
  • alias ls'ls -al colorauto'
  • You can still add other parameters to the aliased
    command

16
Scripting
  • Scripting can be a helpful tool for repetitive
    tasks
  • The beginning of every script starts the same
    !/bin/bash
  • You can use most of the command line calls and
    tricks in a script

17
Basics
  • You can use variables in a script
  • VARvalue
  • You can use expressions for these variables as
    well, such as if you want to name the file with
    the date, use
  • OF/home/Cory/file-(date Ymd)
  • Variables can be accessed using
  • echo hi gt OF

18
If Statements
  • If statements are available in scripts, the basic
    syntax is as follows
  • If foofoo then
  • expression
  • else
  • expression
  • fi

19
For
  • There are two kinds of for
  • One is similar to 'for each' in java, other is
    like the normal 'for'
  • For i in (ls) (use 'seq 1 10' instead for
    normal use)
  • do
  • commands
  • done

20
Functions
  • You can also make functions in scripts
  • Use the syntax
  • function foo
  • Commands
  • echo 1
  • You can use parameters by using the and
    numbers, in order of parameters

21
Why Make Scripts
  • There are many options on how to use a script
    once you've made it. You can alias a command to
    it, put it in a nautilus right click menu, run it
    on login, or even make it auto-execute with a
    cronjob.
  • Aliasing has already been covered, so I will
    explain the other three

22
Running on Login
  • Copy the script into /.bash_profile, or else you
    can just tell it to run your script. This will
    execute it whenever you login
  • You can also put it in /.bashrc, which will
    cause it to run whenever you open up a shell.

23
Add to Nautilus Menu (Gnome)
  • The easiest way is to just add the script into
    the /.gnome2/nautilus-scripts
  • You can also install the nautilus-actions package
    and use it to create your own context-sensitive
    right-click shortcuts.

24
Add to KDE Menu
  • It is also very easy to add this script to your
    KDE desktop. It involves the creation of another
    file. For each script, you need to create a
    shortcut to the script, using the following
    information
  • More information found at link 2 at end of
    presentation

25
Shortcut Settings
  • Desktop Entry
  • EncodingUTF-8
  • ServiceTypesapplication/x-shellsript
  • ActionsActionName
  • Desktop Action ActionName
  • NameName Description
  • Execcommand
  • Iconicon name
  • Move this file to /usr/share/apps/konqueror/servic
    emenus

26
Add as a cronjob
  • First you have to have a crontab set up.
  • This is fairly easy if you don't have one, just
    make a file somewhere, probably home directory,
    and then use the command
  • crontab filename
  • This will then set the file as your current
    crontab.

27
Adding Scripts to a Crontab
  • Adding the script to run is fairly simple. Type
    'crontab -e' to edit it in vi
  • The crontab has a 6 field syntax as follows
  • 'min' 'h' 'd' 'mon' 'wd' 'command'
  • The first 5 say when to run the command, means
    any value. Command is the command you want to run
    at the selected time

28
Crontab Syntax
  • You can also specify multiple times to run a
    command by using commas, for instance
  • 0 0 1 1 /home/Cory/foo will run at 1200AM on
    Jan 1
  • 0 12 1,15 /home/Cory/foo will run on the 1st
    and 15th of every month at noon.

29
The End
  • With These skills, it is very easy to improve the
    speed and usability of your Linux system
  • Questions?

30
Links
  • 1 Linux Tips
  • 2 KDE Script Shortcut
  • 3 Parallel Daemons on Boot
  • 4 Bash Scripting
Write a Comment
User Comments (0)
About PowerShow.com