1、写一个脚本,完成如下功能
(1) 传递一个磁盘设备文件路径给脚本,判断此设备是否存在;
(2) 如果存在,则显示此设备上的所有分区信息;
答:
[root@localhost ~]# cat test2.sh
#!/bin/bash
#
#
if [[ -b $@ ]]; then
fdisk -l $@
fi
[root@localhost ~]# bash test2.sh /dev/sda
Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000d2c5c
Device Boot Start End Blocks Id System
/dev/sda1 * 1 66 524288 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 66 1075 8109056 83 Linux
/dev/sda3 1075 1337 2097152 82 Linux swap / Solaris
/dev/sda4 1337 5221 31206162+ 5 Extended
/dev/sda5 1337 2642 10490313+ 8e Linux LVM
/dev/sda6 2643 3948 10490413+ 8e Linux LVM
2、写一个脚本,完成如下功能
传递一个参数给脚本,此参数为gzip、bzip2或者xz三者之一;
(1) 如果参数1的值为gzip,则使用tar和gzip归档压缩/etc目录至/backups目录中,并命名为/backups/etc-20160613.tar.gz;
(2) 如果参数1的值为bzip2,则使用tar和bzip2归档压缩/etc目录至/backups目录中,并命名为/backups/etc-20160613.tar.bz2;
(3) 如果参数1的值为xz,则使用tar和xz归档压缩/etc目录至/backups目录中,并命名为/backups/etc-20160613.tar.xz;
(4) 其它任意值,则显示错误压缩工具,并执行非正常退出;
答:
[root@localhost ~]# cat 5_2.sh
#!/bin/bash
#
#
cat << EOF
gzip)
bzip2)
xz)
==========
EOF
read -p "Enter a option: " i
case "$i" in
gzip)
tar -zcf /backups/etc-20160613.tar.gz /etc
;;
bzip2)
tar -jcf /backups/etc-20160613.tar.bz2 /etc
;;
xz)
tar -Jcf /backups/etc-20160613.tar.xz /etc
;;
*)
echo "Error compression tool"
exit 1
;;
esac
3、写一个脚本,接受一个路径参数:
(1) 如果为普通文件,则说明其可被正常访问;Can be accessed normally
(2) 如果是目录文件,则说明可对其使用cd命令;Can use the CD command
(3) 如果为符号链接文件,则说明是个访问路径;Access path
(4) 其它为无法判断;Cannot judge
答:
[root@localhost ~]# cat 5_3.sh
#!/bin/bash
#
#
read -p " Enter a file path: " filename
if [ -z "$filename" ]; then
echo "Usage: Enter a file path."
exit 2
fi
if [ ! -e $filename ]; then
echo "No such file."
exit 3
fi
if [ -f $filename ]; then
echo "This path can be accessed normally."
elif [ -d $filename ]; then
echo "You can use the cd command."
elif [ -L $filename ]; then
echo "$filename Is Access Path."
else
echo "Other Type,Can not judge."
fi
4、写一个脚本,取得当前主机的主机名,判断
(1) 如果主机名为空或为localhost,或为"(none)",则将其命名为mail.magedu.com;
(2) 否则,显示现有的主机名即可;
答:
[root@localhost ~]# cat 5_4.sh
#!/bin/bash
#
#
name=`hostname`
if [ -z "$name" ]; then
hostname mail.mage.com
echo "The hostname has been changed to mail.mage.com"
elif [ $name = localhost ]; then
hostname mail.mage.com
echo "The hostname has been changed to mail.mage.com"
elif [ $name = none ]; then
hostname mail.mage.com
echo "The hostname has been changed to mail.mage.com"
else
echo $name
fi
[root@localhost ~]# bash 5_4.sh
The hostname has been changed to mail.mage.com
[root@localhost ~]# bash 5_4.sh
mail.mage.com
5、写一个脚本,完成如下任务 :
(1) 按顺序分别复制/var/log目录下的每个直接文件或子目录至/tmp/test1-testn目录中;
(2) 复制目录时,才使用cp -r命令;
(3) 复制文件时使用cp命令;
(4) 复制链接文件时使用cp -d命令;
(5) 余下的所有类型,使用cp -a命令;
答:
[root@localhost ~]# ls /var/log/
anaconda.ifcfg.log anaconda.syslog boot.log cups lastlog ntpstats secure wtmp
anaconda.log anaconda.xlog btmp dmesg maillog prelink spooler
anaconda.program.log anaconda.yum.log ConsoleKit dmesg.old mcelog sa sssd
anaconda.storage.log audit cron dracut.log messages samba tallylog
[root@localhost ~]# cat 7_5.sh
#!/bin/bash
#
#
for file in $(ls /var/log); do
if [ -d /var/log/$file ]; then
cp -r /var/log/$file /tmp/test1-testn
elif [ -d /var/log/$file ]; then
cp /var/log/$file /tmp/test1-testn
elif [ -h /var/log/$file ]; then
cp -d /var/log/$file /tmp/test1-testn
elif [ -e /var/log/$file ]; then
cp -a /var/log/$file /tmp/test1-testn
else
echo "Can not judge the file"
fi
done
[root@localhost ~]# ls /tmp/test1-testn/
anaconda.ifcfg.log anaconda.syslog boot.log cups lastlog ntpstats secure wtmp
anaconda.log anaconda.xlog btmp dmesg maillog prelink spooler
anaconda.program.log anaconda.yum.log ConsoleKit dmesg.old mcelog sa sssd
anaconda.storage.log audit cron dracut.log messages samba tallylog
6、请详细描述CentOS系统的启动流程(详细到每个过程系统做了哪些事情)
答:
一、POST加电自检 主要是检测硬件设别是否能正常的运行,然而实现自检功能主要是
由镶嵌在主板芯片(CMOS)上的BIOS(basic input output system)程序,检测没问题
之后进行硬件设备的初始化。
二、Boot Sequence(启动管理程序):选择启动顺序加载MBRBoot Sequence是一个程序,
它依赖于某个硬盘硬件,准确的说是第一个硬盘扇区的MBR,从而按次序查找各引导设备。
三、MBR引导,bootloader引导加载器,启动程序 MBR(Master Boot Record):此记录
在0磁道1扇区,总共为512字节,前446字节为bootloder,后64字节为分区表信息,主分区
加上扩展分区不能大于四个,最后2个字节为校验信息,为55AA。提供一个菜单,允许用户
选择要启动的系统或不同的内核版本;把用户选定的内核装载到RAM中的特定空间中,解压、
展开,而后把系统控制权移交给内核。
四、kernel内核实现 kernel自身初始化,实现功能,借助ramdisk探测可识别的程序,
以自读方式挂载根文件系统,运行应用程序:/sbin/init
五、/sbin/init/管理用户空间服务进程 设定运行级别,进行初始化脚本,关闭或
启动相应的程序,启动终端。
六、根切换 在挂载根文件系统时为了避免内核中有bug或操作过程中有bug导致根文件系统
被损坏,先只读挂载根文件系统,加载完成后才读写挂载,完成整个挂载根文件系统后,
直接去找/sbin/init程序,即开始运行用户空间的第一个程序。用户空间启动流程。
七、/sbin/init程序 init程序主要依赖于配置文件:/etc/inittab,大体分为:设定默认启动
级别 --> 设定系统初始化脚本 --> 启动对应级别的服务 --> 打印各终端登录界面
(如果级别为3处理提供文本登录界面,如果级别为5还提供图形登录界面)
八、设置默认运行级别 (1)运行级别:为了系统的运行或维护等目的而设定的机制;
0-6:共7个级别;0:关机,shutdown
1:单用户模式(single user),root用户,无须认证,维护模式;
2:多用户模式(multi user),会启动网络功能,但不会启动NFS,维护模式;
3:多用户模式(multi user),完全功能模式,文本界面;
4:预留级别:目前无特别使用目的,但习惯以同3级别功能使用;
5:多用户模式(multi user),完全功能模式,图形界面;
6:重启
(2)配置文件:/etc/inittab定义了很多功能,每一行定义一种操作(action)以及
与之对应的process(仅适用于CentOS 5),一行就定义了init要执行的任务,甚至是一堆任务
九、系统初始化脚本系统初始化脚本:/etc/rc.d/rc.sysinit
(1)设置主机名;
(2)设置欢迎信息;
(3)激活udev和selinux;
(4)挂载/etc/fstab文件中定义的所有文件系统;
(5)检测根文件系统,并以读写方式重新挂载根文件系统;(重新挂载是指根文件检测完之后)
(6)设置系统时钟;
(7)根据/etc/sysctl.conf文件来设置内核参数;
(8)激活lvm即软raid设备;
(9)激活swap设备;
(10)加载额外设备的驱动程序;(内核加载驱动只加载根文件系统的)
(11)清理操作;注意:在init配置文件:/etc/inittab中,有一行内容是定义/etc/rc.d/rc.sysinit,
此脚本文件是负责完成系统初始化的脚本文件。
十、关闭/启动对应级别下的服务 脚本文件/etc/rc.d/rc作用为当级别切换时启动或停止服务;
此脚本接受传递的参数给脚本中$runlevel变量,然后,读取/etc/rc$runlevel.d/K*和
/etc/rc$runlevel.d/S*所有文件,这些文件就是为什么开机启动后,有些服务会自动启动,
有些服务没有启动的原因。K*:要停止的服务,K##*,优先级,数字越小,越优先关闭,
依赖的服务先关闭,然后再关闭被依赖的。S*:要启动的服务,S##*,优先级,数字越小,
越是优先启动,被依赖的服务先启动,而依赖的服务后启动。/etc/rc.d/init.d目录还有个
链接目录为/etc/init.d目录,这两目录下文件相同。
十一、启动终端(图形终端) 操作系统启动完成。
7、为运行于虚拟机上的CentOS 6添加一块新硬件,提供两个主分区;
(1) 为硬盘新建两个主分区;并为其安装grub;
(2) 为硬盘的第一个主分区提供内核和ramdisk文件; 为第二个分区提供rootfs;
(3) 为rootfs提供bash、ls、cat程序及所依赖的库文件;
(4) 为grub提供配置文件;
(5) 将新的硬盘设置为第一启动项并能够正常启动目标主机;
答:
[root@localhost ~]# fdisk /dev/sdb
Command (m for help): p
Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x58e5f173
Device Boot Start End Blocks Id System
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-2610, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610): +512M
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (67-2610, default 67):
Using default value 67
Last cylinder, +cylinders or +size{K,M,G} (67-2610, default 2610): +10G
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (1373-2610, default 1373):
Using default value 1373
Last cylinder, +cylinders or +size{K,M,G} (1373-2610, default 2610): +1G
Command (m for help): t
Partition number (1-4): 3
Hex code (type L to list codes): 82
Changed system type of partition 3 to 82 (Linux swap / Solaris)
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@localhost ~]# partx -a /dev/sdb
BLKPG: Device or resource busy
error adding partition 1
BLKPG: Device or resource busy
error adding partition 2
BLKPG: Device or resource busy
error adding partition 3
[root@localhost ~]# fdisk -l /dev/sdb
Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x58e5f173
Device Boot Start End Blocks Id System
/dev/sdb1 1 66 530113+ 83 Linux
/dev/sdb2 67 1372 10490445 83 Linux
/dev/sdb3 1373 1504 1060290 82 Linux swap / Solaris
[root@localhost ~]# mkfs.ext4 /dev/sdb1
[root@localhost ~]# mkfs.ext4 /dev/sdb2
[root@localhost ~]# mkswap /dev/sdb3
Setting up swapspace version 1, size = 1060284 KiB
no label, UUID=4bc04463-3119-473c-bb6b-b0b8223391a6
[root@localhost ~]# mkdir /mnt/boot
[root@localhost ~]# mount /dev/sdb1 /mnt/boot/
[root@localhost ~]# grub
grub grub-crypt grub-md5-crypt
grubby grub-install grub-terminfo
[root@localhost ~]# grub-install --root-directory=/mnt /dev/sdb
Probing devices to guess BIOS drives. This may take a long time.
Installation finished. No error reported.
This is the contents of the device map /mnt/boot/grub/device.map.
Check if this is correct or not. If any of the lines is incorrect,
fix it and re-run the script `grub-install'.
(fd0) /dev/fd0
(hd0) /dev/sda
(hd1) /dev/sdb
[root@localhost ~]# ls /mnt/boot/grub/
device.map ffs_stage1_5 minix_stage1_5 stage2 xfs_stage1_5
e2fs_stage1_5 iso9660_stage1_5 reiserfs_stage1_5 ufs2_stage1_5
fat_stage1_5 jfs_stage1_5 stage1 vstafs_stage1_5
[root@localhost ~]# cp /boot/vmlinuz-2.6.32-642.el6.x86_64 /mnt/boot/vmlinuz
[root@localhost ~]# cp /boot/initramfs-2.6.32-642.el6.x86_64.img /mnt/boot/initramfs.i
mg
[root@localhost ~]# vim /mnt/boot/grub/grub.conf
defult=0
timeout=5
title centos (Express)
root (hd0,0)
kernel /vmlinuz ro root=/dev/sda2 selinux=0 init=/bin/bash
initrd /initramfs.img
[root@localhost ~]# mkdir /mnt/sysroot
[root@localhost ~]# mount /dev/sdb2 /mnt/sysroot/
[root@localhost ~]# cd /mnt/sysroot/
[root@localhost sysroot]# mkdir -pv etc bin sbin lib lib64 dev proc sys tmp var usr home root mnt media
mkdir: created directory `etc'
mkdir: created directory `bin'
mkdir: created directory `sbin'
mkdir: created directory `lib'
mkdir: created directory `lib64'
mkdir: created directory `dev'
mkdir: created directory `proc'
mkdir: created directory `sys'
mkdir: created directory `tmp'
mkdir: created directory `var'
mkdir: created directory `usr'
mkdir: created directory `home'
mkdir: created directory `root'
mkdir: created directory `mnt'
mkdir: created directory `media'
[root@localhost sysroot]# cp /bin/bash /mnt/sysroot/bin/
[root@localhost sysroot]# ldd /bin/bash
linux-vdso.so.1 => (0x00007ffebebba000)
libtinfo.so.5 => /lib64/libtinfo.so.5 (0x0000003229a00000)
libdl.so.2 => /lib64/libdl.so.2 (0x0000003227600000)
libc.so.6 => /lib64/libc.so.6 (0x0000003227a00000)
/lib64/ld-linux-x86-64.so.2 (0x0000003227200000)
[root@localhost sysroot]# cp /lib64/lib
Display all 217 possibilities? (y or n)
[root@localhost sysroot]# cp /lib64/libtinfo.so.5 /mnt/sysroot/lib64/
[root@localhost sysroot]# cp /lib64/libdl.so.2 /mnt/sysroot/lib64/
[root@localhost sysroot]# cp /lib64/libdl.so.6 /mnt/sysroot/lib64/
cp: cannot stat `/lib64/libdl.so.6': No such file or directory
[root@localhost sysroot]# cp /lib64/libc.so.6 /mnt/sysroot/lib64/
libc-2.12.so libcgroup.so.1.0.40 libcryptsetup.so.1
libcap-ng.so.0 libcidn-2.12.so libcryptsetup.so.1.1.0
libcap-ng.so.0.0.0 libcidn.so.1 libcrypt.so.1
libcap.so.2 libcom_err.so.2 libc.so.6
libcap.so.2.16 libcom_err.so.2.1
libcgroup.so.1 libcrypt-2.12.so
[root@localhost sysroot]# cp /lib64/libc.so.6 /mnt/sysroot/lib64/
[root@localhost sysroot]# cp /lib64/ld-linux-x86-64.so.2 /mnt/sysroot/lib64/
[root@localhost sysroot]# chroot /mnt/sysroot/
bash-4.1# exit
exit
[root@localhost sysroot]# sync
[root@localhost sysroot]# which ls
alias ls='ls --color=auto'
/bin/ls
[root@localhost sysroot]# ldd /bin/ls
linux-vdso.so.1 => (0x00007ffe43dc3000)
libselinux.so.1 => /lib64/libselinux.so.1 (0x0000003228e00000)
librt.so.1 => /lib64/librt.so.1 (0x0000003228200000)
libcap.so.2 => /lib64/libcap.so.2 (0x000000322ca00000)
libacl.so.1 => /lib64/libacl.so.1 (0x000000322e600000)
libc.so.6 => /lib64/libc.so.6 (0x0000003227a00000)
libdl.so.2 => /lib64/libdl.so.2 (0x0000003227600000)
/lib64/ld-linux-x86-64.so.2 (0x0000003227200000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x0000003227e00000)
libattr.so.1 => /lib64/libattr.so.1 (0x000000322c200000)
[root@localhost sysroot]# cp /lib64/libselinux.so.1 /mnt/sysroot/lib64/
[root@localhost sysroot]# cp /lib64/librt.so.1 /mnt/sysroot/lib64/
[root@localhost sysroot]# cp /lib64/libcap.so.2 /mnt/sysroot/lib64/
[root@localhost sysroot]# cp /lib64/libacl.so.1 /mnt/sysroot/lib64/
[root@localhost sysroot]# cp /lib64/libc.so.6 /mnt/sysroot/lib64/
cp: overwrite `/mnt/sysroot/lib64/libc.so.6'? yes
[root@localhost sysroot]# cp /lib64/libdl.so.2 /mnt/sysroot/lib64/
cp: overwrite `/mnt/sysroot/lib64/libdl.so.2'? yes
[root@localhost sysroot]# cp /lib64/ld-linux-x86-64.so.2 /mnt/sysroot/lib64/
cp: overwrite `/mnt/sysroot/lib64/ld-linux-x86-64.so.2'? yes
[root@localhost sysroot]# cp /lib64/libpthread.so.0 /mnt/sysroot/lib64/
[root@localhost sysroot]# cp /lib64/libattr.so.1 /mnt/sysroot/lib64/
[root@localhost sysroot]# ldd /bin/cat
linux-vdso.so.1 => (0x00007ffc739b0000)
libc.so.6 => /lib64/libc.so.6 (0x0000003227a00000)
/lib64/ld-linux-x86-64.so.2 (0x0000003227200000)
[root@localhost sysroot]# cp /lib64/libc.so.6 /mnt/sysroot/lib64/
cp: overwrite `/mnt/sysroot/lib64/libc.so.6'? yes
[root@localhost sysroot]# cp /lib64/ld-linux-x86-64.so.2 /mnt/sysroot/lib64/
cp: overwrite `/mnt/sysroot/lib64/ld-linux-x86-64.so.2'? yes
###切换硬盘后系统启动。执行LS命令:
######执行CAT命令:
8、写一个脚本
(1) 能接受四个参数:start, stop, restart, status
start: 输出“starting 脚本名 finished.”
...
(2) 其它任意参数,均报错退出;
答:
[root@localhost ~]# cat 5_8.sh
#!/bin/bash
#
#
read -p " Give a option: " option
if [ -z "$option " ]; then
echo "Give a option:"
exit 2
fi
if [ $option = start ]; then
bash 5_4.sh >> /dev/null
echo "starting 5_4.sh finished."
elif [ $option = stop ]; then
bash 5_4.sh >> /dev/null
echo "stoping 5_4.sh finished."
elif [ $option = restart ]; then
bash 5_4.sh >> /dev/null
echo "restarting 5_4.sh finished."
elif [ $option = status ]; then
bash 5_4.sh >> /dev/null
echo "statusing 5_4.sh finished."
else
echo "This is an error option that performs the exit"
fi
exit 1
[root@localhost ~]# bash 5_8.sh
Give a option: test
This is an error option that performs the exit
[root@localhost ~]# bash 5_8.sh
Give a option: restart
restarting 5_4.sh finished.
9、写一个脚本,判断给定的用户是否登录了当前系统;
(1) 如果登录了,则显示用户登录,脚本终止;
(2) 每3秒钟,查看一次用户是否登录;
答:
[root@localhost ~]# useradd chen
[root@localhost ~]# passwd chen
Changing password for user chen.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
[root@localhost ~]# cat 5_9.sh
#!/bin/bash
#
#
read -p " Enter a user: " user
while true;do
if who | grep "^$user" >> /dev/null ; then
break
fi
sleep 3
done
echo "$user is loggin."
[root@localhost ~]# bash 5_9.sh
Enter a user: chen
chen is loggin.
10、写一个脚本,显示用户选定要查看的信息;
cpu) display cpu info
mem) display memory info
disk) display disk info
quit) quit
非此四项选择,则提示错误,并要求用户重新选择,只到其给出正确的选择为止;
答:
#!/bin/bash
#
cat << EOF
cpu) show cpu information;
mem) show memory information;
disk) show disk information;
quit) quit
============================
EOF
read -p "Enter a option: " option
while [ "$option" != 'cpu' -a "$option" != 'mem' -a "$option" != 'disk' -a "$option" != 'quit' ]; do
read -p "Wrong option, Enter again: " option
done
case "$option" in
cpu)
lscpu
;;
mem)
cat /proc/meminfo
;;
disk)
fdisk -l
;;
*)
echo "Quit..."
exit 0
;;
esac
11、写一个脚本
(1) 用函数实现返回一个用户的UID和SHELL;用户名通过参数传递而来;
(2) 提示用户输入一个用户名或输入“quit”退出;
当输入的是用户名,则调用函数显示用户信息;
当用户输入quit,则退出脚本;进一步地:显示键入的用户相关信息后,再次提醒输出用户名或quit:
答:
[root@localhost ~]# cat 5_11.sh
#!/bin/bash
#
#
cat << EOF
username) show user_uid & user_shell;
quit) quit
============================
EOF
function echo_user {
echo -e -n "user_uid:`cat /etc/passwd | grep $username |cut -d: -f3`\t"
echo "user_shell:`cat /etc/passwd | grep $username |cut -d: -f7`"
}
read -p "Enter a username:" username
while true; do
if [ -n "`grep "$username" /etc/passwd`" ]; then
echo_user
read -p "Enter a username:" username
elif [ $username == quit ]; then
break
else
echo "Error input"
read -p "Enter a username:" username
fi
done
[root@localhost ~]# bash 5_11.sh
username) show user_uid & user_shell;
quit) quit
============================
Enter a username:chen
user_uid:500 user_shell:/bin/bash
Enter a username:root
user_uid:0
11 user_shell:/bin/bash
/sbin/nologin
Enter a username:postfix
user_uid:89 user_shell:/sbin/nologin
Enter a username:quit
12、写一个脚本,完成如下功能(使用函数)
(1) 提示用户输入一个可执行命令的名字;获取此命令依赖的所有库文件;
(2) 复制命令文件至/mnt/sysroot目录下的对应的rootfs的路径上,例如,如果复制的文件原路径是/usr/bin/useradd,则复制到/mnt/sysroot/usr/bin/目录中;
(3) 复制此命令依赖的各库文件至/mnt/sysroot目录下的对应的rootfs的路径上;规则同上面命令相关的要求;
答:
#!/bin/bash
#
#
read -p "Enter a command:" command
cat_command=$(which --skip-alias $command )
function copy_command {
cp --parents $cat_command /tmp/tmp | echo "Copy the $command to success"
cp --parents ` ldd cat_command | grep -o "/.*/[^[:space:]]*"` /tmp/tmp |echo "Copy the $command file to success"
}
while true; do
if [ -n "`whereis $command| grep -o "/.*"`" ]; then
ldd $cat_command
copy_command
read -p "Enter a command:" command
else
echo "Error input"
read -p "Enter a command:" command
fi
done