Diff for /wikisrc/tutorials/netbsd_command-line_cheat-sheet.mdwn between versions 1.1 and 1.2

version 1.1, 2011/11/25 00:19:18 version 1.2, 2012/02/05 07:14:36
Line 1 Line 1
 **Contents**  **Contents**
   
 [[!toc levels=2]]  [[!toc levels=2]]
   
 #  Startup & Shutdown  #  Startup & Shutdown 
   
   * Shutdown the machine immediately and reboot    * Shutdown the machine immediately and reboot 
   
 `  `
          
     shutdown -r now      shutdown -r now
   
 `  `
   
   * 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)    * 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) 
   
 `  `
          
     shutdown -p now      shutdown -p now
   
 `  `
   
   * Shutdown the machine and halt afterwards (but keep the power on)    * Shutdown the machine and halt afterwards (but keep the power on) 
   
 `  `
          
     shutdown -h now      shutdown -h now
   
 `  `
   
 #  File & Directory Operations  #  File & Directory Operations 
   
   * Find out what directory you are in    * Find out what directory you are in 
          
     pwd      pwd
   
   * List contents of current working directory    * List contents of current working directory 
          
     ls      ls
   
   * Copy a file to a new file with a different name    * Copy a file to a new file with a different name 
          
     cp foobar.txt barfoo.txt      cp foobar.txt barfoo.txt
   
   * Remove a file (delete it)    * Remove a file (delete it) 
          
     rm foobar.txt      rm foobar.txt
   
   * Remove an ""empty"" directory.    * Remove an ""empty"" directory. 
          
     rmdir mydir      rmdir mydir
   
   * 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.    * 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. 
          
     rm -rf mydir      rm -rf mydir
   
 #  Using Archives  #  Using Archives 
   
   * Create a ""tar"" archive with the contents of a directory displaying each file and directory as tar runs verbosely.    * Create a ""tar"" archive with the contents of a directory displaying each file and directory as tar runs verbosely. 
          
     tar cvf my_archive.tar some_directory      tar cvf my_archive.tar some_directory
   
 The same using pax:  The same using pax: 
          
     pax -w -v -f my_archive.tar some_directory      pax -w -v -f my_archive.tar some_directory
   
   * Extract a ""tar"" archive to the current directory displaying each file and directory as tar runs verbosely.    * Extract a ""tar"" archive to the current directory displaying each file and directory as tar runs verbosely. 
          
     tar xvf my_archive.tar      tar xvf my_archive.tar
   
 The same using pax:  The same using pax: 
          
     pax -r -v -f my_archive.tar      pax -r -v -f my_archive.tar
   
   * Compress a file with gzip using maximum (slowest) compression    * Compress a file with gzip using maximum (slowest) compression 
          
     gzip -9 foobar.txt      gzip -9 foobar.txt
   
   * 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.    * 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. 
          
     bzip2 -9 foobar.txt      bzip2 -9 foobar.txt
   
 #  User Operations  #  User Operations 
   
   * Add a new user and create their home directory    * Add a new user and create their home directory 
          
     [[basics/useradd]] -m jsmith      [[basics/useradd]] -m jsmith
          
   
   * Change a user's default shell    * Change a user's default shell 
          
     [[basics/chsh]] -s /path/newshell jsmith      [[basics/chsh]] -s /path/newshell jsmith
          
   
 or  or 
          
     [[basics/chpass]] -s /bin/ksh jsmith      [[basics/chpass]] -s /bin/ksh jsmith
          
   
 #  Package Operations (pkgsrc)  #  Package Operations (pkgsrc) 
   
   * Add a binary package    * Add a binary package 
          
     pkg_add my_binary_package.tgz      pkg_add my_binary_package.tgz
   
   * List all (installed) packages    * List all (installed) packages 
          
     pkg_info      pkg_info
   
   * List all files that are part of a directory    * List all files that are part of a directory 
          
     pkg_info -L the_package_name      pkg_info -L the_package_name
   
   * Delete a package    * Delete a package 
          
     pkg_delete the_package_name      pkg_delete the_package_name
   
   * Create a binary package file from an already installed package (this requires the **pkg_tarup** tool from pkgsrc which lives under the **pkgtools** subdirectory.)    * Create a binary package file from an already installed package (this requires the **pkg_tarup** tool from pkgsrc which lives under the **pkgtools** subdirectory.) 
          
     pkg_tarup the_package_name      pkg_tarup the_package_name
   
 #  Advanced Command Line Recipes  #  Advanced Command Line Recipes 
   
   * Create a binary package for every single installed package on the system and place them all in the current directory.    * Create a binary package for every single installed package on the system and place them all in the current directory. 
          
          
     for pkg in `pkg_info -e "*" | sort`; do echo "Packaging $pkg"; pkg_tarup -d . $pkg 1>/dev/null; done      for pkg in `pkg_info -e "*" | sort`; do echo "Packaging $pkg"; pkg_tarup -d . $pkg 1>/dev/null; done
          
   

Removed from v.1.1  
changed lines
  Added in v.1.2


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