Herramientas de usuario

Herramientas del sitio


wiki2:linux_commands

¡Esta es una revisión vieja del documento!


Linux commands

Global commands

Uso de servidores

# Mirar el espacio en disco
$ df -h
# Mirar el espacio en memoria
$ free -h
# Mirar la ip
$ ip address

Comprimir y descomprimir

tar -zcvf archive-name.tar.gz directory-name
# Extract
tar -zxvf prog-1-jan-2005.tar.gz
# Extract in a particular directory
tar -zxvf prog-1-jan-2005.tar.gz -C /tmp

Commands

alias

alias emacs="emacs -nw"

apt

Instalar: apt install <package>

Listar paquetes: apt list –<param> <?package>, param=(installed|upgradeable|all-versions)

Mirar distantas versiones de un paquete: apt-cache policiy <package>

Instalar un paquete en una versión concreta: apt install <package>=<version>

You just need to do apt-get install –only-upgrade <packagename>. This will upgrade only that single package, and only if it is installed. If you wish to install the package if it doesn't exist, or upgrade it if it does, you may leave out –only-upgrade.

Set a proxy

Edit apt-conf file (or create a new one if you have no one yet) using the editor of your choice.

sudo nano /etc/apt/apt.conf

Add this line to your /etc/apt/apt.conf file (substitute your details for yourproxyaddress and proxyport).

Acquire::http::Proxy "http://yourproxyaddress:proxyport";

ls

  • Order ls: ls -t
  • For reverse order (most recent at bottom): ls -tr

df

Disk usage.

  • In MB: df -m
  • In a human readable format: df -h

chown

Change the owner:

  • For changing the user and the group recursively: chown www-data: -R .

tail

To see the last lines of a file.

  • For maintaining it reading it use -f parameter.

Others

  • htop → easy to use top command
  • glances → easy to use monitoring command

Move on the paths

cd - goes to the prev visited path.

pushd and popd create a stack of path. If you arrive to a path and want to add it on the stack, you will do pushd .

With dirs command you can see the stack.

You can add this to .bashsrc to add cd + as ot do popd. So when you visit a path you auto add pushd's:

cd()
{
  if [ $# -eq 0 ]; then
    pushd "$HOME" > /dev/null
  elif [ $1 = "+" ]; then
  	popd > /dev/null
  else
    pushd "$@" > /dev/null
  fi
}

Others

Clear and reset

You can do Ctrl+l to clear the screen which is the same than clear command.

To actually reset the scroll and everything you will use the reset command.

wiki2/linux_commands.1547283552.txt.gz · Última modificación: 2020/05/09 09:25 (editor externo)