воскресенье, 17 октября 2010 г.

Basic UNIX/Linux/bash commands

Lets learn some :D

When you start console/terminal you are placed in home(working) directory.
If my username is ilja then i will be placed in /home/ilja/ or for me it will be like ~/.


To know in which directory you are is this command:
# pwd


To list files in current directory:
# ls
And it has variations like
All files(+hidden with dot)  # ls -a
Show rights  # ls -l (about file right and permission will be soon )
Show file size in Kb,Mb,Gb etc # ls -lh
(commonly -h means human readable format ;) )
You can combine it # ls -al


To change directory:
# cd mydir
# cd ~/
To CD to parent directory use ..
# cd ..
#cd ../otherdir


Make directory:
# makedir somedir


Remove(delete) directory:
# rmdir somedir


Remove file:
# rm file
Recursive (all files ,folders and files in them) # rm -r .
It will delete ALL from current dir
Also dont use this without care when you are in root mode or else...you will shit brix

Move file and dir(or rename):
# mv old new

Copy file and dir:
# cp old new

Show filesystems usage(good command):
# df -h

Show files or directories sizes(also good):
# du -h Desktop/
It will show all file sizes(and dirs) in directory Desktop.So on your Desktop.Cool isnt it?

Create blank file:
# touch file

Print contents of file:
# cat file

Edit file:
(there are a lot of editors)
# gedit file
# nano file
# vi file (to exit press :q )

All the time watch file for appended data (for example logs):
# sudo tail -f /var/log/kern.log
(To test try to insert and eject usb flash :P )

Show processes curently runing on terminal:
# ps

Kill process(by PID..watch in ps):
# kill 1234

Kill all processes by name:
# killall test

Make link:
Hard: # ln Desktop MyDesk
Soft(better to use it in common) : # ln -s Desktop MyDesk
because if you will use hard link if you delete MyDesk you will also delete Desktop!

Show date and time:
# date

Show calendar:
# cal

Show commands help:
# man ls
To exit press q

Show who is in system:
# who
And who are you :D
# whoami


Run command as ROOT(superuser):
# sudo command
(Use it wise ;) )

Change password of current user:
# passwd

Shutdown immediatly:
# shutdown -h now
Reboot:
# reboot
(Maybe you must have root access)

Thats all for now.
Thanks for reading.

Комментариев нет:

Отправить комментарий