Showing posts with label Ubuntu. Show all posts
Showing posts with label Ubuntu. Show all posts

Saturday, April 7, 2012

Terminal Commands

System

  • uname -a            -- print system information
  • cat /etc/issue      -– current distribution and version
  • lsb_release -a      -– prints version information for the Linux release
  • date                -– shows the date
  • cal                 -– calculator 
  • fsck                -– File System Check

    Hardware

    • lshw                -- list hardware
    • lspci               -- list all PCI devices 
    • lspci | grep VGA    –- specific graphics card model 
    • hwinfo              -- short overview of all hardware & more detailed info 
    • lsusb               -- USB buses and attached devices

    Processor

    • cat /proc/cpuinfo   -– all processors, clock speeds, flags...
    • cat /proc/loadavg   –- processor load average for the last 1, 5, and 15 min 
    • top                 –- display Linux tasks 
    • uptime              –- current time elapsed since last reboot, users, and load average

      Memory

      • df -h               –- report file system disk space
      • du -sh <path>       –- estimate file space usage
      • cat /proc/meminfo   –- amount of RAM and swap, and how much is being used for what
      • free -m             –- total, used, and free memory shown in MB 
      • df -H               –- partitions, as well as their mount-points and usage in GB

        Drivers & Format

        • sudo fdisk -l       –- all partitions, their device names, and positions on disk

         
        * mount - Mount a Drive
        * umount - Unmount Drive
        * fdisk - Format Disk
        * dd - Dupliate Disk
        * df - Disk Free Space

        Networking

        • ifconfig            –- configure a network interface
        • iwconfig            –- configure a wireless network interface
        • ip addr             –- show / manipulate routing, devices, policy routing and tunnels
        • w                   –- output all currently logged in users and what they’re doing
        chkconfig - Check Activated Services
        * ping - Test Network Connections
        * ftp - file Transfer Protocol
        * host - Check IP of Domain
        * ifconfig - Configure Network Devices
        * netstat - Display Routing Table
        * route - Set Routes
        * telnet - Connect to telnet
        * traceroute - Display Route

        Packages

        • apt-get install/remove          –- install or remove a package
        • aptitude search <packagename>   –-search for a package similar to packagename
        • apt-cache showpkg <packagename> –- packagename’s version and dependencies


            Managing files

            • cp <file> <dest>    –- Copy
            • ls                  –- List
            • mkdir <foldername>  –- Make Directory 
            • mv                  –- Move
            • rm                  –- Remove
            • grep                –- Search for Text Strings
            • head                –- Display Start of File
            • less                –- Display Part of File
            • more                –- Display Part of File
            • tail                –- View the End of a File


            Users

            •  chgroup            –- change a user group

              chmod - Change Mode
              * su - Switch User

            passwd - Create Password
            * groupadd - Add a Group
            * groupmod - Modify a Group
            * chgrp - Change Group
            * groupdel - Delete Group
             

            Other

            • awk                 –- pattern scanning and processing language
            • alias               –- declare symbolic aliases for perl data
            • lshal -m            –- monitor for hardware changes

            Tips

            • sudo lshw -html > your-file-name.html
            • man everything :)

            file - typechecking of one or more ps - the ultimate system monitor for command line - also good for scripts
            * cat - print out a file in the command line

                Friday, April 6, 2012

                Ubuntu/Linux filesystem

                Ubuntu (like all UNIX-like systems) organizes files in a hierarchical tree, where relationships are thought of in teams of children and parent. Directories can contain other directories as well. Also, in every directory, there are two special directories called . and .., which refer respectively to the directory itself, and to its parent directory.

                /bin is a place for most commonly used terminal commands, like ls, mount, rm, etc.
                /boot contains files needed to start up the system, including the Linux kernel, a RAM disk image and bootloader configuration files.
                /dev contains all device files, which are not regular files but instead refer to various hardware devices on the system, including hard drives.
                /etc contains system-global configuration files, which affect the system's behavior for all users.
                /home home sweet home, this is the place for users' home directories.
                /lib contains very important dynamic libraries and kernel modules
                /media is intended as a mount point for external devices, such as hard drives or removable media (floppies, CDs, DVDs).
                /mnt is also a place for mount points, but dedicated specifically to "temporarily mounted" devices, such as network filesystems.
                /opt can be used to store addition software for your system, which is not handled by the package manager.
                /proc is a virtual filesystem that provides a mechanism for kernel to send information to processes.
                /root is the superuser's home directory, not in /home/ to allow for booting the system even if /home is not available.
                /sbin contains important administrative commands that should generally only be employed by the superuser.
                /srv can contain data directories of services such as HTTP (/srv/www/) or FTP.
                /sys is a virtual filesystem that can be accessed to set or obtain information about the kernel's view of the system.
                /tmp is a place for temporary files used by applications.
                /usr contains the majority of user utilities and applications, and partly replicates the root directory structure, containing for instance, among others, /usr/bin/ and /usr/lib.
                /var is dedicated variable data that potentially changes rapidly; a notable directory it contains is /var/log where system log files are kept.

                The root partition / must always physically contain /etc, /bin, /sbin, /lib and /dev, otherwise you won't be able to boot. Typically 150–250MB is needed for the root partition. 



                What about the others directories shown above? Read...
                /usr: contains all user programs (/usr/bin), libraries (/usr/lib), documentation (/usr/share/doc), etc. This is the part of the file system that generally takes up most space. You should provide at least 500MB of disk space. This amount should be increased depending on the number and type of packages you plan to install. A standard Ubuntu desktop requires a minimum of 1.5GB here. A generous workstation or server installation should allow 4–6GB.
                /var: variable data like news articles, e-mails, web sites, databases, the packaging system cache, etc. will be placed under this directory. The size of this directory depends greatly on the usage of your system, but for most people will be dictated by the package management tool's overhead. If you are going to do a full installation of just about everything Ubuntu has to offer, all in one session, setting aside 2 or 3 GB of space for /var should be sufficient. If you are going to install in pieces (that is to say, install services and utilities, followed by text stuff, then X, ...), you can get away with 300–500 MB. If hard drive space is at a premium and you don't plan on doing major system updates, you can get by with as little as 30 or 40 MB.
                /tmp: temporary data created by programs will most likely go in this directory. 40–100MB should usually be enough. Some applications — including archive manipulators, CD/DVD authoring tools, and multimedia software — may use/tmp to temporarily store image files. If you plan to use such applications, you should adjust the space available in /tmpaccordingly.
                /home: every user will put his personal data into a subdirectory of this directory. Its size depends on how many users will be using the system and what files are to be stored in their directories. Depending on your planned usage you should reserve about 100MB for each user, but adapt this value to your needs. Reserve a lot more space if you plan to save a lot of multimedia files (pictures, MP3, movies) in your home directory.



                based on ubuntu wiki