User Tools

Site Tools


perso:dump:lnx:list_of_useful_commands

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
perso:dump:lnx:list_of_useful_commands [2014/01/25 15:50]
Jean-Christophe Berthon [Usage] give example
perso:dump:lnx:list_of_useful_commands [2015/06/18 20:33] (current)
Jean-Christophe Berthon [Deb based package system]
Line 33: Line 33:
 === apt-get commands === === apt-get commands ===
 Here are a dump collection of useful commands with apt/deb system: Here are a dump collection of useful commands with apt/deb system:
-  * ''​apt-get build-dep inkscape'':​ will retrieve the development libraries that are required to build [[:​foss:​wikishelf:​inkscape|inkscape]] +  * ''​%%apt-get build-dep inkscape%%'':​ will retrieve the development libraries that are required to build [[:​foss:​wikishelf:​inkscape|inkscape]] 
-  * ''​apt-get update'':​ fetch the latest list of applications from the repositories +  * ''​%%apt-get update%%'':​ fetch the latest list of applications from the repositories 
-  * ''​apt-get upgrade'':​ upgrade your applications if some newer release are available in the repositories (once synchronised with apt-get update) +  * ''​%%apt-get upgrade%%'':​ upgrade your applications if some newer release are available in the repositories (once synchronised with apt-get update) 
-  * ''​apt-get dist-upgrade'':​ same as before, but smart upgrade are performed (will explained that later, I'm not sure anymore what exactly smart is) +  * ''​%%apt-get dist-upgrade%%'':​ same as before, but smart upgrade are performed (will explained that later, I'm not sure anymore what exactly smart is) 
-  * ''​apt-get source inkscape'':​ get the source of inkscape in your current local directory, ready to be compiled and packaged. +  * ''​%%apt-get source inkscape%%'':​ get the source of inkscape in your current local directory, ready to be compiled and packaged. 
-  * ''​apt-get install inkscape'':​ will install the binary package called inkscape.+  * ''​%%apt-get install inkscape%%'':​ will install the binary package called inkscape. 
 +  * ''​%%apt-get remove inkscape%%'':​ will uninstall the binary package called inkscape (but possibly not all system configuration files) 
 +  * ''​%%apt-get remove --purge inkscape%%'':​ will uninstall the binary package called inkscape (and purge all possible files installed by the package)
  
 === aptitude commands === === aptitude commands ===
-  * ''​aptitude update'':​ fetch the latest list of applications from the repositories +  * ''​%%aptitude update%%'':​ fetch the latest list of applications from the repositories 
-  * ''​aptitude safe-upgrade'':​ upgrade your applications if some newer release are available in the repositories (once synchronised with apt-get update) +  * ''​%%aptitude safe-upgrade%%'':​ upgrade your applications if some newer release are available in the repositories (once synchronised with apt-get update) 
-  * ''​aptitude full-upgrade'':​ same as before, but smart upgrade are performed (will explained that later, I'm not sure anymore what exactly smart is) +  * ''​%%aptitude full-upgrade%%'':​ same as before, but smart upgrade are performed (will explained that later, I'm not sure anymore what exactly smart is) 
-  * ''​aptitude install inkscape'':​ will install the binary package called inkscape. +  * ''​%%aptitude install inkscape%%'':​ will install the binary package called inkscape. 
-  * ''​aptitude remove inkscape'':​ will uninstall the binary package called inkscape.+  * ''​%%aptitude remove inkscape%%'':​ will uninstall the binary package called inkscape.
  
 === dpkg commands === === dpkg commands ===
-  * ''​dpkg --get-selections'':​ will list all installed packaged +  * ''​%%dpkg --get-selections%%'':​ will list all installed packaged 
-  * ''​dpkg-reconfigure packagename'':​ will reconfigure the package, useful to reconfigure some packages such as apache, mysql, xorg, etc.+  * ''​%%dpkg-reconfigure packagename%%'':​ will reconfigure the package, useful to reconfigure some packages such as apache, mysql, xorg, etc. 
 + 
 +=== Checking which services to restart after update/​upgrade === 
 + 
 +  * ''​%%lsof +L1 -R%%''​ 
 +  * Check in the list of files (rightmost column) that the files are under a system folder such as ''/​usr''​ 
  
 === Synaptic package manager === === Synaptic package manager ===
Line 56: Line 64:
  
 ==== RPM based package system ==== ==== RPM based package system ====
 +
 +There is the generic ''​rpm''​ command.
   * ''​rpm -Uvh package.rpm'':​ install a downloaded RPM package   * ''​rpm -Uvh package.rpm'':​ install a downloaded RPM package
-  ​* ''​yum ​update'': ​+ 
 +Then on Fedora (up to release 21) and CentOS/​RHEL,​ there is ''​yum''​ which allows to manage online repository of rpm packages. 
 +  ​* ''​yum ​upgrade'': ​
   * ''​yum install packages'':​ install package(s) from the repositories   * ''​yum install packages'':​ install package(s) from the repositories
   * ''​yum remove packages'':​ remove an installed package(s)   * ''​yum remove packages'':​ remove an installed package(s)
   * ''​yum list'':​ List packages (installed and available)   * ''​yum list'':​ List packages (installed and available)
 +
 +Not always present/​install are plugins for yum to check which services need to be restarted after an upgrade.
 +  * ''​yum ps''​ based on the yum ps plugin;
 +  * ''​needs-restarting''​ based on ;
 +  * Without using yum, and it works for all Linux systems (whether using RPM or not)
 +    * ''​%%lsof +L1 -R%%''​
 +    * Check in the list of files (rightmost column) that the files are under a system folder such as ''/​usr''​
 +
 +Fedora 22 and newer have replaced ''​yum''​ by ''​dnf''​ and it is possible that future releases of CentOS/RHEL will follow suit.
 +  * ''​dnf upgrade'': ​
 +  * ''​dnf install packages'':​ install package(s) from the repositories
 +  * ''​dnf remove packages'':​ remove an installed package(s)
 +  * ''​dnf list'':​ List packages (installed and available)
  
  
Line 97: Line 122:
 <​code>​$ sudo vol_id -u <​device></​code>​ <​code>​$ sudo vol_id -u <​device></​code>​
 One can replace "<​device>"​ by a partition name like /dev/hda1 or /dev/sda5, etc. One can replace "<​device>"​ by a partition name like /dev/hda1 or /dev/sda5, etc.
 +
 +===== File permission =====
 +The set of commands below will create a directory readable by root and users belonging to a group, everyone else can't read it. Only root can write into it.
 +<​code>#​ cd /etc
 +# mkdir nginx
 +# chown root:nginx nginx
 +# chmod 2750 nginx
 +# setfacl -d --set u::​rwx,​g::​rx,​o::​- nginx</​code>​
 +The two first line are obvious. The third line set the permission as rwx for the user, rx for the group and none for others. In addition the setgid bit (g+s or the '​2'​ in '​2750'​) is used to preserve the group ownership of the parent directory to newly create file under it. The last command (only works if your underlying file system supports ACL) set the default permission of rwx for users, rx for group and none for others.
 +
 +With the above setup creating a file under this directory will result in preserving the ownership and rights of the parent directory:
 +<​code>#​ touch nginx/​nginx.conf
 +# mkdir nginx/​vhosts.d
 +# ls -ld nginx/*
 +-rw-r----- 1 root nginx 0 Feb 28 14:50 nginx/​nginx.conf
 +drwxr-s--- 1 root nginx 0 Feb 28 14:50 nginx/​vhosts.d</​code>​
 +
  
 ====== Networking ====== ====== Networking ======
Line 235: Line 277:
     * partimage -bd restore /dev/sda2 sda2-system.000 ​ ;  partimage -bd save /dev/sda2 sda2-system     * partimage -bd restore /dev/sda2 sda2-system.000 ​ ;  partimage -bd save /dev/sda2 sda2-system
   * find $HOME/​workspace -type f -iname "​*.o"​ -print0 | xargs -0 -P 5 rm -f   * find $HOME/​workspace -type f -iname "​*.o"​ -print0 | xargs -0 -P 5 rm -f
-  * zypper search dar+  * zypper (openSUSE/​SLES package manager) 
 +    * Search for dar: zypper search dar
 +    * List available patches (smaller updates): zypper list-patches;​ 
 +    * Info about a patch: zypper info -t patch openSUSE-2015-336;​ 
 +    * Apply available patches: zypper patch; 
 +    * List process(es) that need(s) restart: zypper ps
   * iptraf : nice console HMI for monitoring network traffic   * iptraf : nice console HMI for monitoring network traffic
   * lsof: to verify open files on a filesystem   * lsof: to verify open files on a filesystem
 +  * lsof +L1 -R: to verify list of open files which have been deleted/​changed (e.g. by an update). The owning processes could need a restart.
   * netstat -ltpn   * netstat -ltpn
-  * ethtool eth0+  * ethtool eth0 (and ethtool -i eth0; etc.)
   * Command line monitoring tools:   * Command line monitoring tools:
     * iftop     * iftop
perso/dump/lnx/list_of_useful_commands.1390661404.txt.gz · Last modified: 2015/05/01 23:32 (external edit)