Saturday, July 30, 2011

Basic commands

Commands to work with files and directories:
ls – print list of files and directories
ls -la – print list of files and directories (with hidden)
cd – change current directory
pwd – print current directory
mkdir dir – make a directory named "dir"
rm file –remove file
rm -r dir – remove directory dir
rm -f file – force remove file
rm -rf dir – удалить форсированно каталог dir
cp file1 file2 – copy
cp -r dir1 dir2 – copy dir1 into dir2; if there is no dir2, it will be created
mv file1 file2 – raname or move file1 to file2.
ln -s file link – create a simlink
touch file – create file
cat > file – output to file
less file – printout file
head file – print first 10 lines of file
tail file – print last 10 lines of file
tail -f file – print content of file 

ps – print current active processes
ps aux - print all procesess
ps aux | grep -v grep | grep -i %name - find process %name (you can use part of name)
top – show all running processes
kill pid – kill process by id pid
killall proc – kill all processes named proc
bg – list of stopped tasks and task in background;
fg
fg n
Permission:  
chmod octal file – change permission file to octal,separately for user, group and for all by adding:
4 – read (r)
2 – write (w)
1 – execute (x)
SSH
ssh user@host connect to host as user
ssh -p port user@host connect to host as user by port
ssh-copy-id user@host add your key to host for user to turn on login without password
ethtool - is a command that allows to display or modify a NIC's parameters

scp - is a command to copy files and directories securely between remote hosts (example: scp filename username@hostname:/home/)
uuidgen - command line utility to generate a new UUID value
passwd
- change user password


grep -r 'word_to_find' [path] - find recursively (example: grep -r 'dhcp' /etc*/*)   

No comments:

Post a Comment