QNAP Basic Linux Commands

Viewing, copying, moving and deleting files

 ls Display the contents of the current directory
 ls -a Display also hidden files and hidden directories
 cp filename /path/dir_name Copy filename into directory /path/dir_name
 cp -r dir_name /path/dir_name2 Copy the entire dir_name into /path/dir_name2
 cp filename1 filename2 /path/dir_name Copy filename1 and filename2 into /path/dir_name
 rm name Remove a file or directory called name
 rm -r name Remove an entire directory as well as its included files and subdirectories
 mv filename /path/dir_name Move filename into /path/dir_name
 mv filename1 filename2 Rename filename1 to filename2
 cat filename Display filenames contents
 more filename Display filename in pages. Use spacebar to view next page
 head filename Display filenames first 10 lines
 head -15 filename Display filenames first 15 lines
 tail filename Display filenames last 10 lines
 tail -15 filename Display filenames last 15 lines
 pwd Display current directory
 cd /path/dir_name Change to directory /path/dir_name
 cd .. Go 1 directory up
 mkdir dir_name Create directory dir_name
 rmdir dir_name Delete directory dir_name

Finding files and text within files

updatedbUpdate (create first time used) a database ofall files under the root directory /
locate filenameFind file filename searching in the database
find / -name filenameStarting from the root directory search for the file called filename
find / -name *filenameSame as above but search for file containing the string filename
grep string /path/dir_nameStarting from /path/dir_name search for all files containing string
which application_nameSearch $path for application app_name
whereis application_nameSearch $path, man pages and source files for application_name

Archived files

Decompress

tar -xzf filename.tgzDecompress tzg file
tar -xzf filename.tar.gzDecompress tar.gz file
tar -xjf filename.tar.bz2Decompress tar.bz2 file

 Compress

tar -czf filename.tar /path/dir_nameCompress directory /path/dir_name to filename.tar
gzip -c filename > filename.gzCompress /path/dir_name to filename.tar.gz
bzip2 -c filename > filename.bz2Compress /path/dir_name to filename.tar.bz2

Using rpm files

rpm -hiv package.rpmInstall rpm called package.rpm
rpm -hiv –force package.rpmInstall rpm called package.rpm by force
rpm -hUv package.rpmUpgrade rpm called package.rpm
rpm -e package.rpmDelete rpm called package.rpm
rpm -qpil package.rpmList files in not-installed rpm called package.rpm
rpm -ql package.rpmList files in installed rpm called package.rpm
rpm -q strList installed rpms containing the string str
rpm -qf /path/application_nameDisplay the rpm that contains application application_name

 Starting and Stoping

startxStart the X system
shutdown -h nowShutdown the system now and do not reboot
haltSame as above
shutdown -r nowReboot
rebootSame as above
shutdown -r +10Reboot in 10 minutes

 Mounting filesystems

mount -t vfat /dev/sd(a)(1) /mnt/c_driveMount the first partition 1 of the first hard disk drive a which is in fat32 vfat dormat under /mnt/c_drive directory
mount -t iso9660 /dev/cdrom /mnt/cdromMount cdrom under /mnt/cdrom directory
umount /mnt/hda1Unmout the above

User Administration

usersDisplay users currently logged in
adduser usernameCreate a new user called username
passwd usernameDefine password for user called username
whoList logged-in users
whoamiDisplay current user
finger usernameDisplays info about user username
suLog in as root from current login
su –Log in as root from current login and take root’s path
exitExit from console login (ie, logout).

Processes

commandExecute command in the foreground
command &Execute command in the background
ctrl+zSuspend a program
ctrl+cInterrupt a program
psList all processes
kill -9 pidKill process with id pid
topMonitor processes in real time

Networking

hostnameList the system’s hostname
ifconfigSet/Display network information
host ipResolves ip’s hostname
ping ip/hostnameCheck if ip/hostname is reachable
traceroute ip/hostnameFind network path to ip/hostname

 System Information

uname -aGeneral system information
fdisk -lList partition tables
cp filename /path/dir_nameCopy filename into directory /path/dir_name
df -T -hList filesystem disk space usage
lspciList PCI devices
lsusbList USB devices
free -mDisplay RAM+Swap usage

 Program Compile

gcc -o output file.cCompile a C program
./outputRun a C program you have compiled
g++ -o output file.cppCompile a C++ program
./outputRun a C++ program you have compiled
./configure && make && su -c ‘make install’Configure, compile and install a program with Makefile

Sem comentários:

Enviar um comentário

glpi updates, correcção de erros

#Erros/alertas #1-Web server root directory configuration is not safe as it permits access to non-public files. See installation documentati...