mebioda

Data science tools

UNIX/Linux operating systems: why do we care?

UNIX file system conventions

UNIX-like file systems:

Directory Description
/bin Single user binaries
/dev Hardware devices
/etc Configuration files
/home User home dirs
/lib Libraries
/sbin System binaries
/tmp Temporary files
/usr Multi user utilities
/var Variable files

File access

Commonly-used file operations

Command Function Command Function
ls List files mv Rename/move files
cd Change directory mkdir Make directory
pwd Print working directory rmdir Remove directory
rm Remove files chmod Change file mode
cp Copy files chown Change file owner
# file listing
$ ls

# long (-l) listing of all (-a) files, sizes in (-h) human readable format:
$ ls -lah

# manual pages of ls
$ man ls

File modes

chmod permission bits:

bits code value 2n
001 x 1 20
010 w 2 21
100 r 4 22

Hence:

# set text file rw for user, r for others:
$ chmod 644 file.txt

# set script rwx for user, rx for others:
$ chmod 755 script.sh

Commonly-used text operations

Command Function
more Page through text
head View first lines
tail View last lines
grep Search for pattern
sed Search and replace
sort Sort lines
uniq Filter duplicate lines
cut Cut columns from table
paste Concatenate columns
join Join matching columns
cat Print file contents
wc Word count
awk Tabular data processing

UNIX pipes

UNIX programming

Compiling

Source code can be compiled into binary following standard (optional) steps:

tar -xzf prog.tar.gz
cd prog
(autoconf)
(./configure)
make
sudo make install