Subscribe to Penguin-man the computer guy

Friday, May 10, 2013

Linux Commands

For several years I have been using Ubuntu Linux and overall have become a real enthusiast. I'm sure some old hats might call me a newbie still, and it is true that I still am learning a lot. In some ways, I feel like it takes 2-3 years to get comfortable enough with Linux to start really enjoying it. Anyways, the other day I started taking notes on the normal, and especially the not so normal tasks I do on the terminal. You know there are some things that I just don't do that often... and when I need to do them, I start to wonder, "How did I do that last time? I know it was easy but I can't remember how to do it!!!"

Well, the solution is to write down the commands, so that I would remember them. This is a kind of self documentation of sorts, and I first started doing this maybe a year ago. I more recently started trying to teach someone Linux, and they needed some basics written down. So I've put several of these together and here it is. Feel free to critique, copy, and edit. This is a work in progress that is made to be saved as a .sh in order to be able to see the markup.

-Cal


# Misc Linux Commands
#
# OS:            Using Ubuntu 12.10 Desktop Version
# Author:      Calvin R. Johnson
# Date:          Last update 5-19-2013
# Credits:      Numerous Internet Sources


# Basic Commands

       # To update run:
       sudo apt-get update
       sudo apt-get upgrade

       # Or run this which does both...
       sudo apt-get update && sudo apt-get upgrade

       # Navigate Through Your Filesystem and Directories

               # To change directories run cd
               cd <'path to file'>
               #example is:
               cd /media/flashdrive/anime

               # To change directories to home, run cd ~

                                cd ~

               # To change directories to root, run cd /

                                cd /

               # To change directories back one directory (towards root) run ..

                                $..

                # To List directories run ls:
                        ls
                        syntax = ls (options)
                                ls -l

                # To clear Terminal

                        clear

                # To close Terminal

                        exit

       #To copy files use cp or rsync

       # To use cp (copy)
       cp /media/flashdrive/anime/picture1.jpg /home/heather/pictures/picture1.jpg

       # Or use rsync to copy o whole directory (folder)
       #syntax is:
       rsync [options] <'source'> <'destination'>
       #example
       rsync -avi /media/flashdrive/anime/ /home/heather/pictures/
       #the above copies directory anime from flashdrive to pictures

       # To install software
       # Using apt-get
       sudo apt-get install <'package'>

                        # Before installing many packages, one must add the source or ppa
                        # You will find the ppa listed in the instructions for installing the package
                                sudo apt-add-repository ppa:<package>
                                # Example of adding ppa
                                sudo add-apt-repository ppa:webupd8team/gnome3
                                # Then update
                                sudo apt-get update
                                # Now install
       sudo apt-get install <'package'>
                        # NOTE
                                #When you add a PPA, a new .list file is created under /etc/apt/sources.list.d/.
                                # The files are named based on the PPA name and your Ubuntu version, like this: "someppa-ppa-oneiric.list".
                               
                                # To edit these PPAs, run:
                                        sudo gedit /etc/apt/sources.list.d/*
                        # To remove a ppa
                               sudo add-apt-repository --remove ppa:someppa/ppa
                        # PPA purge
                                sudo apt-get install ppa-purge
                                sudo ppa-purge ppa:someppa/ppa

                # To Find a file
             
                        find file_name

                # Using Wildcards to help find a file

                                find partial_file_name* # or
                                find *partial_file_name

                        # You can also use the wildcard to list file types

                                find *.mp3 # or any other file extension


#************************************************************************************************
# Linux Networking Commands

        # Look up Information:

                sudo ifconfig
                # in windows, >ipconfig

        # To Release and Renew IP Address:

                sudo dhclient

        # To Restart the Networking Service:
        # Always Restart the Networking Service After Changing Network Configurations

                sudo /etc/init.d/networking restart # also (start, stop)

        # Network Config file
        # To Edit the Network Adapter Configurations

                sudo gedit /etc/network/interfaces

        #To Edit the DNS Resolution File

                sudo gedit /etc/resolv.conf

        #To See Current Hostname

                sudo /bin/hostname

        # Hostname
                #To Echo Hostname

                        sudo /bin/hostname newhostname

                #To Change Hostname

                        sudo /bin/hostname newhostname

        # Ping -- To Determine if You Can See an IP Address

                ping <IP Address>

        # To Determine DNS is Working

                ping <domainname>

        # UFW firewall

                # To Change Default Handling of Ports When UFW is Enabled:

                        sudo ufw default allow/deny

                # To Turn UFW on or Off:

                        sudo ufw enable/disable

                # To Open or Close Ports for Everyone:
             
                        sudo ufw allow/deny port#

                # To Delete a UFW Rule:

                        sudo ufw delete allow/deny port#

                # To Allow Access to All Ports from a Specific IP Address:

                        sudo ufw allow from IP Address

                # To Allow Access to a Specific Port from a Specific IP Address:

                        sudo ufw allow from IP Address to any port port#

        # SSH and FTP
                # SSH -- Secure Shell

                        #Install SSH on Server:

                                sudo apt-get install ssh
                                # SSH Requires Port 22
                                # Use a Terminal Emulator to Connect to the Server (PuTTy)

                        # To check the UFW Firewall
     
                                sudo ufw status

                #FTP -- File Transfer Protocol
                        # Install FTP Server

                                sudo apt-get install vsftpd

                        # Edit vsftpd Configuration Files

                                sudo gedit /etc/vsftpd.conf

                                        #Uncoment
                                                #local_enable=YES to Allow Local Users to Login
                                        #Uncomment
                                                #write_enable=YES to Allow File Uploads

                        # To Restart vsftpd Service:
                                sudo service vsftpd restart

                        # Use an FTP Client to Connect to FTP Server (FileZilla)


#*************************************************************************************#
# Some software installation instructions for Ubuntu 12.10 customisations script
        #Terminal Applications

         # SSH
          sudo apt-get install openssh-server


         # g++ & gcc

          sudo apt-get install build-essential

         # gcc for objective C
         sudo apt-get install gobjc


         # Valgrind
         sudo apt-get install valgrind

         # Python

          sudo add-apt-repository ppa:fkrull/deadsnakes
          sudo apt-get update
          sudo apt-get install python2.6 python2.6-dev


         # Ruby

          sudo apt-get install git build-essential

         # Java
         # sudo add-apt-repository ppa:webupd8team/java
         # sudo apt-get install oracle-java7-install
         # sudo apt-get update
         # sudo apt-get remove oracle-java7-installer

         # R

          gpg --keyserver keyserver.ubuntu.com --recv-key E084DAB9
          gpg -a --export E084DAB9 | sudo apt-key add -
          gksudo gedit /etc/apt/sources.list
          # add this line to the bottom of sources.list
          # deb http://cran.ma.imperial.ac.uk/bin/linux/ubuntu precise/
          sudo apt-get update
          sudo apt-get install r-base

        #GUI Apps
         # gedit

          sudo apt-get install gedit
          sudo apt-get check gedit


          sudo apt-get install gedit-plugins

         # Gmate-gedit (for Ruby on rails developers)
         sudo apt-add-repository ppa:ubuntu-on-rails/ppa
         sudo apt-get update
         sudo apt-get install gedit-gmate


         # SciTE

          sudo apt-get install scite
          sudo apt-get check scite

         # Openoffice/libreoffice

          sudo apt-get install libreoffice
          sudo apt-get check libreoffice

         # startup disk creator

          sudo apt-get install usb-creator-gtk
          sudo apt-get check usb-creator-gtk

         # transmition bit torrent

          sudo add-apt-repository ppa:transmissionbt/ppa
          sudo apt-get update
          sudo apt-get install transmission-gtk
          sudo apt-get check transmission-gtk

         # firefox

          sudo apt-get install firefox

         #  Chrome

         # wget https://dl.google.com/linux/direct/google-chrome-stable_current_i386.deb  #32bit version

          wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
          sudo dpkg -i google-chrome*
          sudo apt-get -f install

         # Chromium
  
          sudo apt-get install chromium-browser

         # VLC
       
          sudo apt-get install vlc

         # XBMC
                        sudo add-apt-repository ppa:team-xbmc
                        sudo apt-get update
          sudo apt-get install xbmc

         # Texmacs

          sudo apt-get install texmacs

         # Audacious Music Player

          sudo apt-get install audacious

                #       OpenShot Video Editor
                        sudo add-apt-repository ppa:jonoomph/openshot-edge
                        sudo apt-get update
                        sudo apt-get install openshot openshot-doc

        # Utilities

                # compizconfig-settings-manager
                        sudo apt-get install compizconfig-settings-manager

                # Gparted disk editor
                        sudo apt-get install gparted

                # PPA purge
                        sudo apt-get install ppa-purge
                        #sudo ppa-purge ppa:someppa/ppa

                # Ubuntu Tweak
                        sudo add-apt-repository ppa:tualatrix/ppa
                        sudo apt-get update
                        sudo apt-get install ubuntu-tweak

                # Play encripted DVDs
                        sudo apt-get install libdvdcss2 && sudo /usr/share/doc/libdvdread4/./install-css.sh

                # Extra (Non-Free Codecs)
                        sudo apt-get install non-free-codecs libxine1-ffmpeg gxine mencoder totem-mozilla
                                icedax tagtool easytag id3tool lame   nautilus-script-audio-convert libmad0 mpg321 mpg123libjpeg-prog

No comments:

Post a Comment