Saturday, November 15, 2014

Linux commands

This is a list that is just growing as I learn, for my future reference... I am pretty sure there must be nicer, more organized list out there...
  1. ls to list files.
  2. alias gives an alias to an instruction. For instance, alias ll='ls -al'
  3. cat displays the content of a file without stopping at the end of the page.
  4. more does the same thing but stops at the end of the page. Space will full page fwd. Enter will one line fwd.
  5. less similar to more with more functionality (like seeing previous page by pressing b). ctrl+z to quit.
  6. ps -aux | less Show all processes, long info, one screen at a time
  7. top displays top CPU processes
  8. sudo in front of any command to bypass permissions 
  9. nmap localhost to scan open ports. More details here, here and here. For instance, to increase verbosity level add -v.
  10. file -bi yourfile.html tells you the encoding of your file.
  11. ifconfig tells your IP address among other network stuff... 
  12. Backing up local linux host and remote linux host
  13. Creating and managing users
  14. Managing password expiration
  15. man command gives the manual for that command
  16. chown change the owner of a file
  17. sudo poweroff to completely power off the machine
  18. sudo pm-suspend
  19. sudo pm-hibernate but by default, you can't do it.
  20. sudo reboot
  21. sudo apt-get --purge remove <package>
  22. sudo apt-get install <package>
  23. rm -rf <directory> removes recursively a directory and all the files within. f indicates not to prompt for confirmation. 
  24. which - shows the full path of (shell) commands. 
  25. swapon -s To check the size of the swap space. Good set of commands on swap. What is swap or this one.
  26. at HH:MM executes something at a given time. It'll prompt a cursor for you to enter the command to execute. You can add as many and exit with ctrl+D. atq will show all pending tasks. 
  27. free tells you the memory use
  28. sudo fdisk -l lists the partitions. Or use lsblk or blkid. More on partitions here. It doesn't hurt to refresh what cylinders, sectors, etc... are. 
  29. inxi will give a lot of system information (hardware, drivers...). -G tells you about the graphics. -b is basic info. 
  30. tail - output the last part of files  
  31. sudo iotop -a Shows read/write process activity
  32. lshw -short lists all the hardware...
  33. lsblk lists the drives (block type devices attached)
  34. dd if=/dev/sda of=~/hdadisk.img to backup the disk (need su)
  35. cp -r dir1/ ~/Pictures/ copy dir1 contents into Pictures directory in the home directory
  36. rm -rf mint Delete mint directory and all stuff included on it
  37. alias hdd='cd /media/edusson/SP\ PHD\ U3' Type hdd to change to /media/edusson/SP PHD U3 directory. Notice the use of \ as escape code for the empty space.
  38. sudo blkid (for all partitions) or sudo blkid /dev/sdb1 to check if a given partition is encrypted.
Editors:
  1. vi editor. Basic commands. Press : to get to the command. q! will exit without saving.
  2. nano quick editor
  3. subl more fancy editor. Go to Synaptic package manager, type sublime in the search, then click on the box to install and apply changes... Or go to their website, download the linux installer untar, etc... and install...
Bash (Bourne Again shell):
  1. Use & at the end of a command to launch it independent of terminal.
  2. history shows the history of commands. Terminal command history tricks
  3. Double click on something to highlight it. Right click to paste it on the prompt.
  4. Break a Unix command between lines with \
  5. Press tab to autofill what is left
System variables:
  1. See a variable: echo $variable_name. For instance, echo $SHLVL
  2. Set a variable with export. For intance, export PS1="\u@\h \w> "
  3. SHLVL: level of bash you are in. See here.
  4. PS1, PS2, PS3 and PS4: prompt statement. Lots of options.
  5. PROMPT_COMMAND: Bash shell executes the content of the PROMPT_COMMAND just before displaying the PS1 variable. For instance, export PROMPT_COMMAND="date +%k:%m:%S"
  6. HOME
  7. PATH
 Boot order (in Mint):
  1. On GRUB (bootloader)
  2. /etc/bash.bashrc
  3. /etc/bash_completion (called by the previous one if it exists)
  4. /usr/share/bash-completion/bash_completion. Called by the previous one, this file is huge.
  5. ~/.profile executed by the command interpreter for login shells. This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login exists.
At exit:
  1. ~/.bash_logout
Directories/folders:
  1. home or also indicated as ~. The base directory for the specific user
  2. proc: running processes, drivers, hardware info...
  3. /etc/default: default settings for the programs
  4. /var/log: system log files To see them you can just use the GUI log viewer
  5. /proc directory. Very special virtual directory

Notes:
  1. Suspend and hibernate with Linux, a whole other beast. Start here. Check also my two posts on the topic...
  2. Good explanation to .so, .a, .dll etc...

References:
  1. http://www.linfo.org/
  2. 50 Linux admin commands

Ten things to do when you just got mint:
https://www.youtube.com/watch?v=h_rIFm5Ygw0

Update the System:
sudo apt-get update
sudo apt-get dist-upgrade

Yakuake dropdown terminal:
sudo apt-get install yakuake

Get old wallpaper:
sudo apt-get install mint-backgrounds-*

Install Flash Player:
sudo apt-get install flashplugin-installer

Install Restricted Extras:
sudo apt-get install ubuntu-restricted-extras

Codecs & Enable DVD Playback:
sudo apt-get install gstreamer0.10-plugins-ugly libxine1-ffmpeg gxine mencoder libdvdread4 totem-mozilla icedax tagtool easytag id3tool lame nautilus-script-audio-convert libmad0 mpg321 libavcodec-extra

Enable DVD Playback:
sudo /usr/share/doc/libdvdread4/install-css.s­h

Install Dropbox:
sudo apt-get install dropbox python-gpgme

Skype:
sudo apt-get install skype

wget -O skype.deb http://download.skype.com/linux/skype...
sudo dpkg -i skype.deb
sudo apt-get -f install;rm skype.deb

(64bit) fix skin issue with this command:
sudo apt-get install gtk2-engines-murrine:i386 gtk2-engines-pixbuf:i386 sni-qt:i386

Install rar and other archiving utilities:
sudo apt-get install p7zip-rar p7zip-full unace unrar zip unzip sharutils rar uudeview mpack arj cabextract file-roller

Install a clipboard manager:
sudo apt-get install clipit

Hardinfo - System information tool:
sudo apt-get install hardinfo

Install Firewall
sudo apt install gufw

Cleanup:
sudo apt-get autoremove

No comments:

Post a Comment