Posts Tagged ‘linux’

Linux command for LPIC preparation

LPIC 1 Objectives

history -d 100
history -c = clears the history

Occasionally, the problem arises where you can’t remember the exact name of a command to look up
$ man -k “system information”
dumpe2fs (8) – dump ext2/ext3/ext4 filesystem information
uname (1) – print system information

Linux file descriptor:
Standard Input (STDIN) = 0
Standard Output (STDOUT) = 1
Standard Error (STDERR) = 2

date +%M

mkdir -p /home/yuko/a/b/c
mv -f /tmp/A/* /targetfolder

rm -Rf /tmp/A /*

cp -Rf /tmp/A/* /targetfolder
echo ‘$HOME’ = $HOME

echo “$HOME” = /home/yuko

echo `date +%M` = 50
lsattr filename

Continue reading

/bin/bash^M: bad interpreter: No such file or directory

Sometime when working with shell script, we need to edit the shell script on Windows environment. Then when we execute the shell script on Linux environment, we will find the below error:

/bin/bash^M: bad interpreter: No such file or directory
/bin/bash^M: bad interpreter: そのようなファイルやディレクトリはありません

Since the new line code had been saved in the \ r \ n, there is a need to fix in the Linux \ n. This is because the new line code had been saved in the \ r \ n on Windows environment. In order to fix the problem, we need to convert the \r\n to \n on Linux environment. To do this, we may use the below command:

$ sed -i 's/\r//' [shell script fileName]

Below, verification

By using the command cat -e, we can see that there is additional \ r at the newline code.

$ cat -e
echo "hello,world"^M$
This remains to run an error
$ ./
-bash: ./ /bin/bash^M: bad interpreter: No such file or directory
Convert line feed code by using sed command
$ sed -i 's/\r//'
once again check with cat -e
$ cat -e
echo "hello,world"$
Then, you are done!
$ ./
%d bloggers like this: