Annotation of wikisrc/tutorials/netbsd_command-line_cheat-sheet.mdwn, revision 1.1

1.1     ! mspo        1: **Contents**
        !             2: 
        !             3: [[!toc levels=2]]
        !             4: 
        !             5: #  Startup & Shutdown 
        !             6: 
        !             7:   * Shutdown the machine immediately and reboot 
        !             8: 
        !             9: `
        !            10:     
        !            11:     shutdown -r now
        !            12: 
        !            13: `
        !            14: 
        !            15:   * Shutdown the machine and immediately power off (for ATX hardware, you will need to install and enable the [apm(8)](http://netbsd.gw.com/cgi-bin/man-cgi?apm+8+NetBSD-current) support in kernel: see [[How to poweroff at shutdown]] for details) 
        !            16: 
        !            17: `
        !            18:     
        !            19:     shutdown -p now
        !            20: 
        !            21: `
        !            22: 
        !            23:   * Shutdown the machine and halt afterwards (but keep the power on) 
        !            24: 
        !            25: `
        !            26:     
        !            27:     shutdown -h now
        !            28: 
        !            29: `
        !            30: 
        !            31: #  File & Directory Operations 
        !            32: 
        !            33:   * Find out what directory you are in 
        !            34:     
        !            35:     pwd
        !            36: 
        !            37:   * List contents of current working directory 
        !            38:     
        !            39:     ls
        !            40: 
        !            41:   * Copy a file to a new file with a different name 
        !            42:     
        !            43:     cp foobar.txt barfoo.txt
        !            44: 
        !            45:   * Remove a file (delete it) 
        !            46:     
        !            47:     rm foobar.txt
        !            48: 
        !            49:   * Remove an ""empty"" directory. 
        !            50:     
        !            51:     rmdir mydir
        !            52: 
        !            53:   * Recursively remove a directory (be careful with this, if you mess up, you can easily wipe out your whole system). This will remove the directory and all the files and subdirectories it contains, provided you have permissions. 
        !            54:     
        !            55:     rm -rf mydir
        !            56: 
        !            57: #  Using Archives 
        !            58: 
        !            59:   * Create a ""tar"" archive with the contents of a directory displaying each file and directory as tar runs verbosely. 
        !            60:     
        !            61:     tar cvf my_archive.tar some_directory
        !            62: 
        !            63: The same using pax: 
        !            64:     
        !            65:     pax -w -v -f my_archive.tar some_directory
        !            66: 
        !            67:   * Extract a ""tar"" archive to the current directory displaying each file and directory as tar runs verbosely. 
        !            68:     
        !            69:     tar xvf my_archive.tar
        !            70: 
        !            71: The same using pax: 
        !            72:     
        !            73:     pax -r -v -f my_archive.tar
        !            74: 
        !            75:   * Compress a file with gzip using maximum (slowest) compression 
        !            76:     
        !            77:     gzip -9 foobar.txt
        !            78: 
        !            79:   * Compress a file with bzip2 using maximum (slowest) compression. Bzip generally compresses files better at the cost of greater time during the compression phase. The archives it creates generally de-compress at the same speed as gzip. 
        !            80:     
        !            81:     bzip2 -9 foobar.txt
        !            82: 
        !            83: #  User Operations 
        !            84: 
        !            85:   * Add a new user and create their home directory 
        !            86:     
        !            87:     [[basics/useradd]] -m jsmith
        !            88:     
        !            89: 
        !            90:   * Change a user's default shell 
        !            91:     
        !            92:     [[basics/chsh]] -s /path/newshell jsmith
        !            93:     
        !            94: 
        !            95: or 
        !            96:     
        !            97:     [[basics/chpass]] -s /bin/ksh jsmith
        !            98:     
        !            99: 
        !           100: #  Package Operations (pkgsrc) 
        !           101: 
        !           102:   * Add a binary package 
        !           103:     
        !           104:     pkg_add my_binary_package.tgz
        !           105: 
        !           106:   * List all (installed) packages 
        !           107:     
        !           108:     pkg_info
        !           109: 
        !           110:   * List all files that are part of a directory 
        !           111:     
        !           112:     pkg_info -L the_package_name
        !           113: 
        !           114:   * Delete a package 
        !           115:     
        !           116:     pkg_delete the_package_name
        !           117: 
        !           118:   * Create a binary package file from an already installed package (this requires the **pkg_tarup** tool from pkgsrc which lives under the **pkgtools** subdirectory.) 
        !           119:     
        !           120:     pkg_tarup the_package_name
        !           121: 
        !           122: #  Advanced Command Line Recipes 
        !           123: 
        !           124:   * Create a binary package for every single installed package on the system and place them all in the current directory. 
        !           125:     
        !           126:     
        !           127:     for pkg in `pkg_info -e "*" | sort`; do echo "Packaging $pkg"; pkg_tarup -d . $pkg 1>/dev/null; done
        !           128:     
        !           129: 

CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb