Command Line: how to update ubuntu, check disk free, free ram, linux, etc.

Learnt:
how to update ubuntu and install stuff using APT – advanced package tool
how to upgrade:

sudo apt-get update

how to install:
apt-get install programName

how to check what linux distribution i’m using:

cat /etc/*-release
//it outputs the contents of any file in the etc folder that ends in “-release”

or uname -a //for mac

how to check free RAM:
free -h
// -h means output in human numbers like gigabytes

how to check what computer i’m using:
cat /proc/cpuinfo
// must enter the first / because it means find from root folder, not the current folder.

how much space available on the system:
df -h
//disk free, -h human-readable

how much space files/folders take up on the system:
sudo du / -hd1
//disk usage from / root folder, in human-readable, depth 1 level down.

Advertisements

Command Line. Tar, Sed, Awk, Grep, Find,

today i learnt how to
use tar to compress into an archive:
tar -caf nameOfArchive.tar file1 file2 fileN

to extract:
tar -xf nameOfArchive.tar -C folder
i also learnt how to use sed to substitute
sed “s/wordtoSub/subword/” file

also learnt about grep and find.

find is to find a file within the folders:

find . -name “*.jpg”

find and copy files:

find -name “*.jpg” -print0 | xargs -0 cp -t folder/
//the -print0 and -0 is to ignore spaces and special characters.
// -print will make everything on one line.
grep is to find text within a file:

grep “the” filename

grep -i “the” filename

grep -E “[hijk]” filename

grep -E “\w{6,}” filename
// grab words with 8 or more chars.
I also learnt a valuable lesson in Lynda’s lesson for command line – i learnt how to awk into a log file.

Need to refresh memory on awk.
awk ‘{print $2}’ filename

Remember it’s single quotes, double doesn’t work at all – does nothing.