Basic Linux

By | 27/04/2014

file management

removes a full directory:

rm -rf directoy1
rm -rf directory2
rm -rf directory?

find files

find -name FILENAME

disk usage

du /directory -h
du /directory -c | grep total

disk management

Swap

Create swap sdaX partition using gparted

sudo mkswap /dev/sdaX
sudo swapon /dev/sdaX

Edit /etc/fstab to include the following line

/dev/sdaX none swap sw 0 0

Swap status

swapon -s

command line

move up or down – shift PageUp / PageDown

repeats the previous command with sudo

sudo !!

software installation

apt-get

update apt-get sources

apt-get update

install a package

apt-get install package

dpkg

install a package

dpkg -i package

 

services

service –status-all

 

random

/dev/random – provides random numbers with good quality, but it can hold the request if there is no enough entropy

/dev/urandom – provides random with lower quality without holding the requests. Requires less entropy

 

tar

uncompres a tar.gz file

tar -xvf file.tar.gz

 

System settings

GNOME configuration system

dconf-editor

Grub Installation

sudo apt-get update
sudo apt-get install grub2
sudo update-grub2
grub-install -v //verify installation

 

Mount drives automatically

1) get UUID of the drives

sudo blkid

2) Modify /etc/fstab

sudo gedit /etc/fstab

Add the following line:

[UUID] [MountPoint] [FileSystem] [Options] [Dump] [Pass]
UUID=AAABBBCCC /mnt/drive1 ntfs 0 0 0

 

Move all files including subfolders to a new folder

find /src/dir -type f -exec mv --backup=numbered -t /dst/dir {} +

Reference - http://superuser.com/questions/658075/how-do-i-move-files-out-of-nested-subdirectories-into-another-folder-in-ubuntu

vi

Edit mode – i
Exit edit more – esc

Delete all lines :1,$d
: - run command
1,$ - from line 1 to eof
d - delete

 

network

host file – /etc/hosts

 

Leave a Reply