Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

Files and folders

Linux has a single directory 'tree', separated by slash, the top is the 'root'. All additional disks are connected on /mnt ('mounted'). In Linux, there is no concept of driver letters.

...

Code Block
$ tree -a
.
├── 000.txt
├── 001.txt
├── 002.txt
├── 009.txt
├── 010.txt
├── a.txt
├── A.txt
├── b.txt
├── B.txt
├── c.txt
├── C.txt
├── garbage
│   ├── garbage_01
│   ├── garbage_02
│   └── garbage_03
├── .hidden
│   └── youfoundit.txt
├── my_data.dat
├── my-data.txt
├── z.txt
└── Z.txt

2 directories, 19 files

File permissions

Linux has a method to keep files private and safe. When you type ls -a you will get a lot of information of your directory including files such as

...

chmod 750 my_file1.txt: set the user has read, write, and executable permissions; group has read/executable permission; others no permission.

Cat

The cat (short for “concatenate“) command is one of the most frequently used command in Linux. cat command allows us to create single or multiple files, view contain of file, concatenate files and redirect output in terminal or files.

...

more, less, and most (most has more features than more and less commands) are commands to open a given file for interactive reading.

Redirection

Redirection is a feature such that when you execute a command with it, you can change the standard input/output devices. The standard input (stdin) device is the keyboard, and the standard output (stdout) device is the screen. With redirection, stdin/stdout can be changed.

...

eg. matlab > outfile 2>&1 : send stdout and stderr to 'outfile'. Here 1 and 2 are file descriptors. File descriptor 1 is the standard output (stdout), and 2 is the standard error (stderr). > is redirection, and & indicates that what follows and precedes is a file descriptor and not a filename.

Wildcards

Wildcards are symbols or special characters that represent other characters. You can use them with any command such as ls/rm/cp etc.

...

For more informaiton, refer to https://wiki.hpcc.msu.edu/display/ITH/Regular+Expressions

man

Linux includes a built in manual for nearly all commands. Type ‘man’ followed by the commands.

...

Note that options can be with single dash ‘-‘ or double dash ‘—’

wc, grep, sort, head, tail

wc: count words, lines or characters

...

tail: list only last n lines of file

zip, unzip, tar

unzip: unzip

tar: create (tar -c) or extract (tar -x) ‘tape archive’ file.

...

Can you tar all files and folders in workshop folder? Question? Use man. 

Environment variables

Shell maintains and you can set ‘variables’ that the shell uses for configuration and in your script. Variables start with $, and can be seen with echo $VARNAME

...