Linux Skills

<?xml version="1.0" encoding="utf-8"?>

Linux Skills

In this post, I will record the daily usage of linux, as well as the ways toresolve the common problems.

1 How to use ramdisk in Ubuntu and Fedora?

In Fedora, the ramdisk is disabled by default, that is, it is compiled intothe kernel, but as a module, which will be loaded into the kernel whenactually used. So, it is necessary to compile the kernel manually to selectthe ramdisk as the built-in modules.

In Ubuntu, the ramdisk support is enabled by default, so the steps are easiercompared to Fedora.

Using the following commands to list the ramdisk:

ls /dev/ram*

The output will be like:

/dev/ram0 /dev/ram10 /dev/ram12 /dev/ram14 /dev/ram2 /dev/ram4 /dev/ram6 /dev/ram8
/dev/ram1 /dev/ram11 /dev/ram13 /dev/ram15 /dev/ram3 /dev/ram5 /dev/ram7 /dev/ram9

Format the ramdisk as an ext4fs:

mkfs.ext4 /dev/ram1

Then mount it:

sudo mount /dev/ram1 /mnt

2 How to enable ssh server in Ubuntu?

By default, Ubuntu doesn't install the ssh server, so the following commandwill fail:

ssh localhost
ssh: connect to host localhost port 22: Connection refused

Using the following command to install the ssh-server:

sudo apt-get install openssh-server

Then all things will go well.

3 How to disable CPU in Linux?

It is easy to do with real root user:

echo 0 > /sys/devices/system/cpu/cpuX/online

The CPU status can be checked by:

cat /proc/cpuinfo

To re-enable the CPU:

echo 1 > /sys/devices/system/cpu/cpuX/online

4 How to disable SELinux in Linux?

The SELinux has some negative effect on the self-defined filesystem, so it isnecessary to disable it, using the following command:

sestatus\\

will list the status of the SELinux,

SELinux status: enabled
SELinuxfs mount: /sys/fs/selinux
SELinux root directory: /etc/selinux
Loaded policy name: targeted
Current mode: enforcing
Mode from config file: enforcing
Policy MLS status: enabled
Policy deny_unknown status: allowed
Max kernel policy version: 28

To change the status of SELinux, modify the configure file in:

/etc/selinux/config\\

5 How to deal with the errors in MP3 files in Rythmbox under Ubuntu?

The easiest way is as follows:

sudo gedit /etc/profile

Add the following two lines to the end of the file:

export PATH=$PATH GST_ID3_TAG_ENCODING=GBK:UTF-8:GB18030
export PATH=$PATH GST_ID3V2_TAG_ENCODING=GBK:UTF-8:GB18030

This enables the Chinese characters to be recoginized by the system.

6 How to accelerate the ssh connection?

I am working on a project which has something to do with a remote server, andI have to ssh to that server, but the server is Fedora and my os is Ubuntu,and it turns out it takes a long time to resove the host/server IP, thesolution to this problem is:

ssh -o GSSAPIAuthentication=no user@yourserver

7 When something goes wrong in ubuntu ?

Afer a failed attempt to upgrade the Ubuntu13.10 to Ubuntu 14.04, the systemshows a popup window everytime the system boots, the title of the window is"System Program Problem Detected". The following method can be used to solvethe problem:

sudo rm /var/crush/*

This command will delete the crushed software of the system so that thereporting utility won't work, thus eliminating the annoying message.

8 How to umount a filesystem even when it is busy?

Recently, a project requires frequently mounting and testing a filesystem,and it is very likely that the newly-mounted filesystem will crash for allkinds of reasons, and after the accident, it is no longer possible to umountthe filesystem in a normal way. The error message from the OS is as follows:


With the -l option of umount, the result can be seen as follows:

9 How to sync files without copying the originals when using Cloud Storage?

When using CloudDrive, it is likely that the software may only allow you tosynchronize the files or folders under a specific folder, if you have manyother directories to synchronize, you have to copy files, but there is asimple way to achieve the same goal without copying files—the symboliclink.
In Linux,the following command can be used to create a symbolic link toanother directory:

ln -s target-folder link-name

\\

In windows, use the following command:

mklink /J link-name target-folder

10 How to rename multiple files at a time?

  1. Add extention to all the files in a directory:\\
    for f in *;do mv "$f" "$f.png";done
  2. Rename:\\
    rename 's/old-name/new-name/' files

11 What is the most amazing ssh option you have encountered?

The first useful option of ssh is the GSSAPIAuthentication=no, whichaccelerates the connection startup time. Another useful option is the X11forwarding, with the -X option, you can use the X11 application from thelocalhost.(Especially for emacs).

12 When Ubuntu Xsession goes wrong….

The problem I encountered is like this:
When I want to logout the xsession of ubuntu, it fails to close all therunning application and return back to the login screen, so I start aterminal by ALT+CRTL+F1, from which I did a reboot. After the system booted,I typed my password to my account, but it returned back to the login sessionagain, and the process continued.

There was some error messages in ~/.xsession-error file, and the mode bits of ~/.xauthority file has changed to root only, so the correct way to deal withthe problem is use the following command:

sudo chmod +x 777 .Xauthority

Author: wujing

Created: 2014-04-29 二 12:38

Emacs 24.3.1 (Org mode 8.2.6)

Validate

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值