Computer OS Commands

# Install ncftp client
apt-get install ncftp
# Install compress tools
apt-get install unrar-free
apt-get install p7zip-full
# Download folder
ncftpget –R –v –u <ftpUser> <ftpServer> client-path server-folder-path
# Upload folder
ncftpput -R -v -u <ftpUser> <ftpServer> server-path client-folder-path
# Compression
tar -zcvf [path]<compression-filename>.tar.gz [path]<compressed-files>
# Decompression
tar -xzvf [path]<compression-filename>.tar.gz
The later command extracts the entire compressed data, restoring folder structure as well.
# Compile standalone executable program for Java on Linux
# create a Java program
$ cat > Hello.java <<'END'
public class Hello {
public static void main(String args[]) {
System.out.println("Hello, World!");
}
}
END
# install Java compiler
$ apt-get install gcj-jdk && gcj -v
# compile the Java program
$ gcj --main=Hello -g -o hello Hello.java
# run the program
$ ./hello
Hello, World
# list Dynamic Dependencies of the program
$ ldd ./hello
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x007a2000)
libgcj.so.5 => /usr/lib/libgcj.so.5 (0x02e8f000)
libm.so.6 => /lib/tls/libm.so.6 (0x0063b000)
libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00666000)
libz.so.1 => /usr/lib/libz.so.1 (0x0075b000)
libdl.so.2 => /lib/libdl.so.2 (0x00660000)
libc.so.6 => /lib/tls/libc.so.6 (0x00509000)
/lib/ld-linux.so.2 (0x004ef000)
libgcj.so.5 library needs to be shipped with the program. If you want it to be statically integrated into the program, please use -static-libgcj compile option. This option may not work on some Linux distros because the library is not included in the gcj package, then please try gcc instead. screen command
# start screen with a session name
screen -S <session-name>
# attach to a screen session
screen -r <session-name>
# open a screen window
screen -r <session-name> -t <window-name>
# send command to a screen window
screen -r <session-name> -p <windowID|window-name> -X stuff <command>
# quit a screen session
screen -X -S <session_name> quit
System states
# list running processes
ps -Awwo pid,comm,args
# get process ID
ps auxf | grep <program-file-name> | grep -v grep | awk '{print $2}'
pidof <program-name>
# check network
netstat -tap |grep LISTEN
netstat -a | egrep 'Proto|LISTEN'
ssh
- problem: Failed to open a secure file transfer session
- Solution:
- open: /etc/ssh/sshd_config
check the parameter of sftp path which should point to an existing one:
Subsystem sftp /usr/lib/openssh/sftp-server
- restart ssh service