Sei sulla pagina 1di 5

Check Hard disk Size and Usage:

df -H

1. Logging Out:
gnome-session-save ?ogout

2. Change Adapter Settings:


Open network configuration file
$ sudo vi /etc/network/interfacesOR$ sudo nano /etc/network/interfaces

Find and remove dhcp entry:


iface eth0 inet dhcp

Append new network settings:


iface eth0 inet static address 192.168.1.100 netmask 255.255.255.0 network 192.168.1.0 broadcast 192.168.1.255 gateway 192.168.1.254

Save and close the file. Restart the network:


$ sudo /etc/init.d/networking restart

Task: Define new DNS servers


Open /etc/resolv.conf file
$ sudo vi /etc/resolv.conf

You need to remove old DNS server assigned by DHCP server:


search myisp.com nameserver 192.168.1.254 nameserver 202.54.1.20 nameserver 202.54.1.30

3. Make Files Immutable


By setting the file as immutable, any user including super-user cannot write or delete the file but they can read it. Below is an example on how to set an immutable file attribute.
To make your file (test_file) immutable # chattr +i test_file ... You can only do it logged in as root. Here the +i option sets the immutable bit for the file. Once this bit is set, even root can't delete or tamper with the file. If you want to unset the immutable flag, just run the following command: # chattr -i test_file You can check what are the attributes of a file by using the following command: # lsattr test_file ----i-------- test_file

If the immutable flag is set, there will be an 'i' in the listing. This command is used by system administrators to restrict the users from changing a file in a particular way or even the administrator can by mistake delete a critical file because of a mis-typed command. But if the immutable flag is set, these mistakes can be avoided. chattr can be used to set/unset many more file attributes. Like if you want to allow everybody to just append data to a file and not change already entered data, you can set the append bit as follows: # chattr +a test_file Now the test_file can only be opened in append mode for writing data. You can unset the append attribute as follows: # chattr -a test_file To know more about this very useful tool in the system administrator's forte, check the man page forchattr.

4. Remove Folder and Subfolders and Files


rm -rf ./folder and becareful ...... this erases files without asking anything.

5. Enable and Disable Root Account


sudo passwd root

This will ask for a new root password and once you confirm it, you can start using the root account to login. In case you will want to disable back the root account, just lock the root account by running:
sudo passwd -l root

l< Creating directories >


Creating a new, empty directory is very easy. You use the mkdir command: $ mkdir dir1 That's it. It's really that easy!

l< Removing directories >


There are two commands you can use for removing directories. If the directory is empty, you can use rmdir: $ rmdir dir1 You can use rmdir only if the directory is empty. If you want to remove a directory with all its contents, you can use rm with the -r option. The -r option tells rm to remove a directory recursively: $ rm -r dir1 It goes without saying that you can cause a lot of trouble with rm -r if you're not careful! In some cases it might be a good thing to use the -i option when deleting a directory with its contents so that you'd be prompted before each file in the directory gets deleted: $ rm -ir dir1

l< Copying and moving directories >


For copying and moving directories you can use the cp and mv commands just like you use them with files. Yeah, I know. If you've already tried to copy a directory with cp, you've probably noticed that cp just complains at you. Probably it says something like cp: omitting directory yadda yadda. You see, the cp command wants you to use the -r option if you want to copy a directory with its contents. The -r means "copy recursively": $ cp -r dir1 dir2 The above creates a directory named dir2 whose contents will be identical to dir1. However, if dir2 already exists, nothing will be overwritten: the directory dir1 will be copied into the dir2 directory under the name dir2/dir1. When renaming directories, you use the mv command exactly the same way as with files: $ mv dir1 dir2 When dealing with directories, mv works a bit like cp does. If dir2 doesn't exist, the above will rename dir1 to dir2, but if dir2 exists, the directory dir1 will be moved into the dir2 directory under the name dir2/dir1.

lLinux scp command syntax and examples


The Linux scp command is a very useful tool for a remote copy. It is a better option than rcp because it uses encryption just like ssh program. In fact, it uses ssh for data transfer authentication. That means, you certainly need to provide login name and password of the target/destination computer. To start using Linux scp program, let's look at the most important part, the command syntax or command format. This is the Linux scp command syntax to send file or directory to a remote computer: scp -r [/path/filename] [login name@ip address] : . This is the Linux scp command syntax to retrieve file or directory from a remote computer: scp -r [login name@ip address] : [/path/filename] . Here are the meaning of scp command options: -r = recursively copy entire directory . = current directory '/path/filename' is the complete directory path and name where the file resides. 'login name@ip address ' is the target/destination computer. You have to provide your login name and ip address and will be asked for user password. Dot (.) at the end of the command means the files will be copied to the current directory. Of course you can change the destination to any directory you wish, just type the full path and directory name to replace the dot(.). You can find more details in the scp manual page by invoking man scp from Linux command line terminal, which is recommended, if you could at least read it once to get a better understand of the command. Now that you already understand how scp command works, let's see some actual examples taken from Ubuntu client. Example on how to send file to a remote computer with scp command in Ubuntu Linux using ip address:

luzar@ubuntu:~$ scp UserManual.pdf luzar@192.168.1.6:. luzar@192.168.1.6's password: UserManual.pdf 100% 3812KB luzar@ubuntu:~$

3.7MB/s

00:01

The scp command example above shows I am sending a file named UserManual.pdf from my computer to a remote computer with an ip address 192.168.1.6. The file UserManual.pdf must be in our home directory. If not, please provide a complete directory path. The file will be saved in luzar's home directory. I specified the user name which I want to login with (remember that we need to provide a valid username and password) and enter the password afterward. Here is the example on how to retrieve file from a remote computer using scp command in Linux. This time we are using remote server's hostname:
luzar@ubuntu:~$ scp luzar@slackware:/home/luzar/netfilter.pdf . luzar@slackware's password: netfilter.pdf 100% 367KB 367.2KB/s luzar@ubuntu:~$ 00:00

The scp command example above shows that I was retrieving a file named netfilter.pdf from a remote computer with an ip address 192.168.1.6. Notice that this time I used a full directory path to the file which I want to get. We can also use scp command to transfer multiple files at once to a remote computer. See the example below:
luzar@ubuntu:~$ scp Interfaces.txt new_file02.txt labu@10.21.36.3:. Password: Interfaces.txt 100% 268 0.3KB/s new_file02.txt 100% 51 0.1KB/s luzar@ubuntu:~$ 00:00 00:00

We can also use wild card with scp command such as * to copy all files. If you feel that copying the whole directory is a better idea, here is an example of scp command used to transfer a directory to a remote computer:
luzar@ubuntu:~$ scp -r folder labu@10.21.36.3:. Password: luzar@ubuntu:~$

We use scp -r option in the example above to recursively copying a directory named folder. You can also use scp command to transfer file or directory to other Linux computer using Windows operating system. Get Putty to login to the Linux server and use scp to copy file or directory to a remote computer (Linux computer) just as examples above. Adding Proxy Adding system wide proxy
Edit the file /etc/environment, for example with this command: gksu /etc/environment (it will ask you for your password, because you need to do it as a root)

now, add the following line to that file: http_proxy="http://my.proxy.address:port" where 'my.proxy.address' and 'port' need to be replaced with the respective values you wish to use. Save the file and relog -- make sure the setting is there by opening a terminal and ussuing the command: export | grep http_proxy You might be also interested in the fact that apt (the application that performs the installation of packages in Ubuntu) has some support for proxy. Edit Nano /etc/apt/apt.conf add for example Acquire::http::proxy "http://192.168.170.25:3135/"; Acquire::ftp::proxy "ftp://192.168.170.25:3135/"; Acquire::https::proxy "https://192.168.170.25:3135/";

Shut Down Command


The shutdown command can be used to turn off or reboot a computer. Type the command as follows to shutdown server / computer immediately: $ sudo shutdown -h now OR $ sudo shutdown -h 0

How do I shutdown compute at specific time?


To shutdown computer at 6:45pm, enter: $ sudo shutdown -h 18:45 "Server is going down for maintenance" At 6:30pm message will go out to all user and 6:45 system will shutdown. Please note that you can also use halt or poweroff or reboot command for stopping and restarting the system: $ sudo halt OR $ sudo poweroff

How do I reboot computer?


Simply use reboot command: $ sudo reboot OR $ sudo shutdown -r 0

Potrebbero piacerti anche