Howto to start working with basic bash shell commands
From KhoLiX Wiki
Contents |
[edit] ReadMe
- SSH Bash Shell commands are limited on Kholix shell server. Not every bash command will work on Kholix shell especially which required privilege access. But Kholix shell server configured with basic need for those programmers for PHP, Python, Perl and Java. If you want more binary to execute on your shell environment, please contact support@kholix.com with your description.
- Shell access required your true personal identity by network administrator admin@kholix.com.
[edit] Target Audience
- Hosting account(s) which has SSH access to Kholix shell server
- For Window user
- New Linux/Unix user
- New Mac user
- New to command line interface user
- None Graphical User Interface (GUI) user
- Read SSH article for your SSH clients
[edit] Basic BASH Commands on Kholix Server
[edit] touch
touch -- to create new file
user@nighthawk$touch test.txt
[edit] joe
joe -- joe command line text editor
user@nighthawk$joe test.txt
Invoke commands insides joe editor (joe commands need to hold down control key while pressing two characters' switches)
^ -- sign represent for Control key ^KH -- to turn on/off joe editor help menu ^KD -- to save test file ^KX -- to save and exit ^KZ -- to suspend current editing and visit shell fg -- to return previous suspended joe editing session (only if suspended session) ^C -- to abort editing ^C , y -- to exit without save
[edit] vi
vi -- vi command line text editor
user@nighthawk$vi test.txt
Invoke basic commands inside vi editor
:q! -- to exit without save :wq -- to save and exit i (or) insert -- to insert/edit text Shift D -- to delete line yy -- to copy line p -- to paste line Page Up -- to scroll page up Page Down -- to scroll page down
[edit] nano
nano -- nano command line text editor
user@nighthawk$nano test.txt
CTRL+O (not zero, Control + Character O) -- overwrite/modify text file
CTRL+X -- to exit/quit nano editor
[edit] cat
cat -- to view file contents
user@nighthawk$cat test.txt
[edit] chmod
chmod -- to change file permission
user@nighthawk$chmod 644 test.txt user@nighthawk$chmod 666 test.txt user@nighthawk$chmod 777 test.txt user@nighthawk$chmod 755 Folder user@nighthawk$chmod 777 Folder
chmod a+rwX test.txt (WORLD) chmod ug+rwX test.txt (USER.GROUP) chmod o-rwx test.txt (EVERYBODY IS REJECTED)
[edit] ls
ls -- list current directory contents
user@nighthawk$ls user@nighthawk$ls -a user@nighthawk$ls -l user@nighthawk$ls -al user@nighthawk$ls -alh
Note: ll -- is short form of ls -al. By default for limited user account or jailed user, this command is not enabled. You can create shell alias to use this command, read follow by alias section. h -switch view by KB/MB.
[edit] df
df -- Report how much free disk space is available for each mount you have.
df -h -l
[edit] du
du -- Tells you how much space a file occupies.
du -a
http://www.computerhope.com/unix/udu.htm
[edit] alias
alias -- create your own shortcut commands with shell aliases.
user@nighthawk$alias ll='ls -al' user@nighthawk$alias ll='ls -al'
- Read also Alias (Unix shell) entry.
[edit] rm
rm -- remove/delete of files (use with caution)
user@nighthawk$rm test.txt user@nighthawk$rm -rvf directory
Switches
-r -- recursive -v -- verbose output -f -- force -h -- print help
[edit] unzip
unzip -- to unzip/inflating the zipped file
user@nighthawk$unzip test.zip
[edit] zip
- In this example, filename.zip represents the file you are creating and filesdir represents the directory you want to put in the new zip file. The -r option specifies that you want to include all files contained in the filesdir directory recursively.
zip -r filename.zip filesdir
- You can use zip to compress multiple files and directories at the same time by listing them with a space between each one:
zip -r filename.zip file1 file2 file3 /usr/work/school
[edit] bzip2/bunzip2
bzip2 -- to compress/de-compress with bzip2 format De-compress
user@nighthawk$bzip2 -d test.bz2 user@nighthawk$bunzip2 test.bz2
Compress
user@nighthawk$bzip2 test user@nighthawk$bzip2 -z test
- You can use bzip2 to compress multiple files and directories at the same time by listing them with a space between each one:
bzip2 filename.bz2 file1 file2 file3 /usr/work/school
[edit] gzip/gunzip
gzip -- to compress/de-compress with gzip format
- To use gzip to compress a file, type the following command at a shell prompt. The file will be compressed and saved as filename.gz.
gzip filename
- To expand the compressed file, type the following command. The filename.gz is deleted and replaced with filename.
gunzip filename.gz
- The following command compresses file1, file2, file3, and the contents of the /usr/work/school directory (assuming this directory exists) and places them in a file named filename.gz.
gzip -r filename.gz file1 file2 file3 /usr/work/school
[edit] tar
tar -- to inflate the tar archive file
user@nighthawk$tar -xzvf test.tar.gz user@nighthawk$tar -xzpf test.tgz user@nighthawk$tar -xjvf test.tar.bz2 user@nighthawk$tar -xf test.tar
tar -- to create the tar archive file
user@nighthawk$tar -czvf foldername.tar.gz folder-directory user@nighthawk$tar -czvf test.tar.gz test user@nighthawk$tar -czpf test.tgz test
[edit] mv
mv -- move files to new place
user@nighthawk$mv test.txt /home/projects/myproject/
[edit] cp
cp -- copy files to new place
user@nighthawk$cp test.txt /home/projects/myproject/
[edit] mkdir
mkdir -- make new directory
user@nighthawk$mkdir test
[edit] wget
wget -- direct download packages from shell to directory
user@nighthawk$wget http://www.examplesoftwaresite.com/software.tar.gz
[edit] curl
curl -- direct download packages from shell to directory
user@nighthawk$curl -O http://www.examplesoftwaresite.com/software.tar.gz
[edit] More
More about bash shell commands
- Search through Google's Linux
- http://www.ss64.com/bash/
- Oreilly bash command
- http://www.linuxcommand.org/
- http://www.gnu.org/software/bash/manual/bash.html
- http://www.reallylinux.com/docs/admin.shtml

