Last active
July 18, 2018 09:39
-
-
Save gonzaloamadio/aec2a85f9713588c77d1aa4d1ca5e42d to your computer and use it in GitHub Desktop.
Various linux commands for administrators, and for everyone
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- Connect to windows via rdesktop --- | |
> rdesktop -u administrador -g1500x800 10.11.11.97 | |
--- Connect to linux via ssh --- | |
> ssh {user}@{ip or dns-name} | |
Example | |
> ssh [email protected] | |
Here a prompt will appear and you must put the password | |
--- Mysql --- | |
> mysql -u root -p | |
> {Put password here} | |
Create User: | |
> CREATE USER 'gamadio'@'localhost' IDENTIFIED BY '1123'; | |
Then to enter being in terminal | |
> mysql -u {user} -p | |
> 1123 | |
Grant privileges, from root | |
> GRANT all privileges ON TABLE {db.table} TO {user}; | |
Borrar usuario: | |
> SELECT User FROM mysql.user; | |
> show grants for ‘{user}’@'localhost'; | |
> REVOKE ALL PRIVILEGES, GRANT OPTION FROM ‘{user}’@'localhost'; | |
> drop user ‘{user}’@'localhost'; | |
> drop user {user}; | |
Show info of table | |
>SHOW CREATE TABLE `<yourtable>`; | |
Modificate Table | |
> ALTER TABLE <yourtable> ADD queued VARCHAR(3); | |
Actualizar valor de un campo | |
> UPDATE chatrooms SET queued="yes" WHERE roomname=”sinpass”; | |
--- Copy files via ssh to other machine (scp) --- | |
For example, file /Documentos/arch.html from local machine, to machine with ip 10.11.11.97 and the user emilio. | |
We will copy in the same destination (must exist and emilio have permission to write) | |
> scp /Documentos/arch.html [email protected]:/Documentos | |
scp syntax: scp source_file_name username@destination_host:destination_folder | |
--- Varios --- | |
> tar xzf archivo.tar.gz (extraer) | |
> tar -czf new-file.tar.gz file1 file2 folder1 folder2 (crear) | |
> tar tvfz er.tar.gz | less (ver que hay adentro) | |
> mv archivo archivoQueNoExiste (renombrar) | |
> mv archivo carpetaDestino (copiar archivo) | |
> mv carpeta carpetaDestino (copiar carpeta) | |
> rm archivo (borrar) | |
> vi archivoQueNoExiste (crear archivo) | |
> pwd (nos muestra la ruta del directorio actual) | |
> ls -l (nos muestra archivos con permisos) | |
> ps afxu | |
--- RSYNC --- | |
Copy, syncronizing only differences | |
>rsync -avz --exclude "*~" --exclude archivo1 /home/gonzalo/proyecto1/ root@servidordestino:/opt/proyecto1/ | |
>rsync -avz root@servidororigen:/home/{user}/development/proyecto1/ root@servidordestino:/opt/proyecto1/ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment