<commit_before># Table of content for linux commands
 * [Environment](#environment)
 * [Directory](#directory)
 * [Files](#files)
 * [vim](#vim)
 * [Permissions and Groups](#permissions-and-groups)
 * [wget](#wget)
 * [tar](#tar)

## Environment
**path name of the files which would be executed in current environment**
```which nodejs```
**who is logged in**
```who```
**clear screen**
```clear```
**change password**
```passwd```
**move file across ssh**
```scp /pwd/fileName amaskey@ip:pwd/fileName```

## Directory
**print working directory**
```pwd```
**list directory**
```
ls -alt
 -a 	hidden files and folders
 -l 	more details
 -t 	newest first
ls -sh
 -s 	size
 -h 	human readable
ls -d */							#show directory only
ls -la | less							#one page at a time
ls intel*							#all files starting with intel.
ls /								#look at root
```
**create or delete**
```
mkdir
rmdir
rm -r 								#recursively remove dir and all the files
```
**change**
```
cd 
cd ../FolderName 						# go to parent directory and open folder
cd ~ or cd 							# home
cd - 								# back to last directory
```
**copy or move**
```
mv ./* ~Google/							# move all files and folders
cp -a ./sourceFolder ./targetFolder 
```
**estimate file space usage**
```
du -hs
  -h	human readable
  -s 	size
```

## vim
```vim fileName```
**insert mode**
```
i 	#insert before cursor
I	#insert at the beginning of the line
a	#append after cursor
A	#append at the end of the line
esc	#end insert mode
```
**quit**
```
:q	#quit
:wq	#save and exit
:q!	#quit without saving
```
**split screen**
```:split fileName```
**goto line number**
```:512```
**find phrase**
```? phrase```

## permissions and groups
**current permission**
```
ll
  -rwxrwxrwx	username	group
  drws------
```
 * first: dash '-' then normal file, if 'd' then directory
 * next 3 = owner permission: r (read), w(write), x(execute), -(no permission) 
 * next 3 = group permission
 * final 3 = rest of the world permission
 * first - owner of file
 * second - group the file belongs to #groups <username> to get groups memmbership
 
**change permission**
```
chmod 664 test.html ( rw-rw-r-- )
```
**permission number representation**
```
0(---), 1(--x), 2(-w-), 3(-wx), 4(r--), 5(r-x), 6(rw-), 7(rwx)
```
**take ownership**
```
chown <username> -R filename
```
**recursively change ownership of all files and folders**
```
chown -R hduser:hduser /opt/hdfs
```
**add user to group**
```
usermod -aG sudo <username>
```

## wget
**download file**
```
wget http://www.example.com/filename
```
**download entire website**
```
wget -r http://www.example.com
```
**download entire website and external links**
```
wget -r -H http://www.example.com
```<commit_msg>organize linus cmd-7<commit_after># Table of content for linux commands
 * [Environment](#environment)
 * [Directory](#directory)
 * [Files](#files)
 * [vim](#vim)
 * [Permissions and Groups](#permissions-and-groups)
 * [wget](#wget)
 * [tar](#tar)

## Environment
**path name of the files which would be executed in current environment**
```which nodejs```

**who is logged in**
```who```

**clear screen**
```clear```

**change password**
```passwd```

**move file across ssh**
```scp /pwd/fileName amaskey@ip:pwd/fileName```

## Directory
**print working directory**
```pwd```

**list directory**
```
ls -alt
 -a 	hidden files and folders
 -l 	more details
 -t 	newest first
ls -sh
 -s 	size
 -h 	human readable
ls -d */							#show directory only
ls -la | less							#one page at a time
ls intel*							#all files starting with intel.
ls /								#look at root
```
**create or delete**
```
mkdir
rmdir
rm -r 								#recursively remove dir and all the files
```
**change**
```
cd 
cd ../FolderName 						# go to parent directory and open folder
cd ~ or cd 							# home
cd - 								# back to last directory
```
**copy or move**
```
mv ./* ~Google/							# move all files and folders
cp -a ./sourceFolder ./targetFolder 
```
**estimate file space usage**
```
du -hs
  -h	human readable
  -s 	size
```

## vim
```vim fileName```

**insert mode**
```
i 	#insert before cursor
I	#insert at the beginning of the line
a	#append after cursor
A	#append at the end of the line
esc	#end insert mode
```
**quit**
```
:q	#quit
:wq	#save and exit
:q!	#quit without saving
```
**split screen**
```:split fileName```

**goto line number**
```:512```

**find phrase**
```? phrase```

## permissions and groups
**current permission**
```
ll
  -rwxrwxrwx	username	group
  drws------
```
 * first: dash '-' then normal file, if 'd' then directory
 * next 3 = owner permission: r (read), w(write), x(execute), -(no permission) 
 * next 3 = group permission
 * final 3 = rest of the world permission
 * first - owner of file
 * second - group the file belongs to #groups <username> to get groups memmbership
 
**change permission**
```chmod 664 test.html ( rw-rw-r-- )```

**permission number representation**
```0(---), 1(--x), 2(-w-), 3(-wx), 4(r--), 5(r-x), 6(rw-), 7(rwx)```

**take ownership**
```chown <username> -R filename```

**recursively change ownership of all files and folders**
```chown -R hduser:hduser /opt/hdfs```

**add user to group**
```usermod -aG sudo <username>```


## wget
**download file**
```
wget http://www.example.com/filename
```
**download entire website**
```
wget -r http://www.example.com
```
**download entire website and external links**
```
wget -r -H http://www.example.com
```
{'fraction_non_alphanumeric': 0.18156528189910978, 'fraction_numerical': 0.006491097922848665, 'mean_word_length': 3.566469093988146, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6241855', 'n_tokens_mistral': 2068, 'n_tokens_neox': 1800, 'n_words': 670}