How to check free space in Ubuntu?

The sizes of files and directories can be listed using:
ls -l

To see the free space left in partitions, use:
df -h

Other filters for df are given below:

Apache access.log format And Status Codes

Operating System: Windows XP SP2 
Server: localhost
Sample String from access.log: 127.0.0.1 - frank [10/Oct/2000:13:55:36 -0700] "GET /apache_pb.gif HTTP/1.0" 200 2326
Each part of this log entry is described below.
127.0.0.1 (%h)
This is the IP address of the client (remote host) which made the request to the server. If HostnameLookups is set to On, then the server will try to determine the hostname and log it in place of the IP address. However, this configuration is not recommended since it can significantly slow the server. Instead, it is best to use a log post-processor such as logresolve to determine the hostnames. The IP address reported here is not necessarily the address of the machine at which the user is sitting. If a proxy server exists between the user and the server, this address will be the address of the proxy, rather than the originating machine.

Effective C++ Ed. 3rd: Item 27. Minimise casting

Instead of "old" C style casts:



(T) expression             // cast expression to be of type T 
T(expression)           // cast expression to be of type T



Prefer C++ style-casts:

Effective C++ Ed. 3rd: Item 26. Postpone variable definitions as long as possible

  1. Postpone a variable's definition until right before you have to use the variable
  2. Try to postpone the definition until you have initialization arguments for it. 
  3. By doing so, you avoid constructing and destructing unneeded objects, and you avoid unnecessary default constructions. 
  4. This help document the purpose of variables by initializing them in contexts in which their meaning is clear.
prev | next

    Effective C++ Ed. 3rd: Item 25 Consider support for non-throwing swap.

    Contents:
    •     Default Swap
    •     Member Swaps
    •     Non-member swaps
    •     Specializations of std::swaps
    •     calls to swap

    Swap has become a mainstay. Swap is a very useful function. It's important to implement it properly. Among many uses, it is a common mechanism for coping with the possibility of assignment to self. A typical implementation in std is:
    namespace std {
    template  <>        // typical implementation of std::swap;
    void swap(T& a, T& b)         // swaps a's and b's values  
    {
        T temp(a);
        a = b;
        b = temp;
      }
    }
    

    To override swap function:

    Effective C++ Ed. 3rd: Item 24. Declare non-member functions when type conversions should apply to all parameters

    Way 1:
    class Rational {
    public:
        Rational(int numerator = 0,        // ctor is deliberately not explicit;
            int denominator = 1);     // allows implicit int-to-Rational conversions
            int numerator() const;             // accessors for numerator and
            int denominator() const;           // denominator
    
            const Rational operator*(const Rational& rhs) const;
        private:
        ...
    };
    
    Rational oneEighth(1, 8);
    Rational oneHalf(1, 2);
    result = oneHalf * 2;                             // fine - oneHalf.operator*(2);
    result = 2 * oneHalf;                             // error! - 2.operator*(oneHalf);
    
    Way2:
    class Rational {
      ...                                             // contains no operator*
    };
    
    const Rational operator*(const Rational& lhs,     // now a non-member
                             const Rational& rhs)     // function
    {
      return Rational(lhs.numerator() * rhs.numerator(),
                      lhs.denominator() * rhs.denominator());
    }
    
    Rational oneFourth(1, 4);
    Rational result;
    result = oneFourth * 2;                           // fine
    result = 2 * oneFourth;                           // hooray, it works!
    
    Result: As multiplication should be commutative, Way2 should be used when type conversions should apply to all parameters.

    prev | next
    Cheers and try hosting at Linode.

    Effective C++ Ed. 3rd: Item 23. Prefer non-member non-friend functions to member functions

    Reasons to prefer non-member non-friend functions to member functions: 
    1. Encapsulation: More functions present in a class, lesser is the encapsulation.
    2. Modularity: Functionality of a class in terms of non-member functions or convenience functions can be defined in different header files in the same namespace. This will enable us to include only required functionality along with the class. For example: Functionality of standard library in namespace std is partitioned into many header files viz. vector, iostream, list etc. 
    3. Extensibility: Writing convenience function as mentioned in above point lets other users extend the functionality. This can be done by defining more code in a new header file with the same namespace.
      prev | next
      Cheers and try hosting at Linode.

      Effective C++ Ed. 3rd: Item 22. Declare data members private


      Declare members private for :
      1. Syntactic Consistency: Every call-able member would be a function.
      2. Granular Accessibility: Using "setter" and "get" functions
      3. Encapsulation:
        • Implement functions the way it suits best. For example: On embedded devices: it must use less memory whereas on other machines, it may be allowed to take more memory to speed it up more.
        • Private data members put more restriction on their interaction with the users as compared to protected and public data members. So removing private data member (to change some implementation) leads to less broken code relatively.
      prev | next
      Cheers and try hosting at Linode.

      Ubuntu Server: How to list all the groups and users

      Linux is a multi-user operating system.  This means that the administrator will have to be careful in how users are managed. List of users is maintained in /etc/passwd along with more information like the group the belong to etc. To view its contents, run: cat /etc/passwd
      The each line of output is like:
      www-data:x:33:33:www-data:/var/www:/bin/sh
      Here there are 7 items mentioned below in order from left to right:

      Effective C++ Ed. 3rd: Item 21. Don't try to return a reference when you must return an object

      1. Remember not to return reference to a local object/variable in any function. As local variable/objects dies as soon as function ends.
      2. Remember not to return a dynamically allocated object (using new operator). User of the function may forget corresponding delete call.
      3. Remember not to return reference to a local static object/variable in any function say f().
        In this case f(obj1, ...) = = f(obj2, ...) will always comes true.
      4. Instead return the object by value.
      prev | next
      Cheers and try hosting at Linode.